mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
Compare commits
109 Commits
2.0-alpha4
...
2.0-alpha5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0cbf59209b | ||
|
|
1fce1ac905 | ||
|
|
b9a955c048 | ||
|
|
5a577e5e4c | ||
|
|
f648172625 | ||
|
|
4b41dd30e6 | ||
|
|
2a416d1f1d | ||
|
|
23f338b0c3 | ||
|
|
cdcea91b50 | ||
|
|
4549c97e51 | ||
|
|
fc3cc12038 | ||
|
|
62ea117f45 | ||
|
|
3d8ff5b585 | ||
|
|
a3b95c1c38 | ||
|
|
2308099260 | ||
|
|
4a3da3abe7 | ||
|
|
3e4811791a | ||
|
|
34f12ac39c | ||
|
|
af98c2636c | ||
|
|
f21b331844 | ||
|
|
ea628af580 | ||
|
|
9cae8a412a | ||
|
|
47b7befd2f | ||
|
|
2fcc369c41 | ||
|
|
66b3d22041 | ||
|
|
03e4b2d13c | ||
|
|
c83579ecdb | ||
|
|
a26119ea20 | ||
|
|
98c821df05 | ||
|
|
a992c76d6a | ||
|
|
f2dfef8c41 | ||
|
|
cb804eb143 | ||
|
|
74e912ccd3 | ||
|
|
1f47033835 | ||
|
|
3fcfc348ed | ||
|
|
6b33298a6e | ||
|
|
68e1fc0cd0 | ||
|
|
31796d33fb | ||
|
|
755241df5c | ||
|
|
9080864167 | ||
|
|
d25e883983 | ||
|
|
091e87aeb3 | ||
|
|
4a870f61f1 | ||
|
|
5daf0853c9 | ||
|
|
ef3d7b7772 | ||
|
|
7dde8a771f | ||
|
|
3dd4681e69 | ||
|
|
98d888063b | ||
|
|
9c788a6e84 | ||
|
|
e087baeb48 | ||
|
|
b64276c4e8 | ||
|
|
f7dd63a126 | ||
|
|
a68a86f19b | ||
|
|
984b23de70 | ||
|
|
d5b70b1bef | ||
|
|
551637f0c2 | ||
|
|
8778df5789 | ||
|
|
67338aac7b | ||
|
|
626351c5da | ||
|
|
6504b6f2bd | ||
|
|
035271d469 | ||
|
|
5c84aa308d | ||
|
|
e1c82a4453 | ||
|
|
db6ac26794 | ||
|
|
a505d85792 | ||
|
|
6df30df992 | ||
|
|
0ec29b2354 | ||
|
|
f1bebe904a | ||
|
|
e16720d06d | ||
|
|
3be7fa6b3b | ||
|
|
e99e3ae6ca | ||
|
|
d182586557 | ||
|
|
1f5564760f | ||
|
|
2be045eb8f | ||
|
|
7a89510916 | ||
|
|
5588792344 | ||
|
|
3acb33e05a | ||
|
|
61ee763515 | ||
|
|
3658a65380 | ||
|
|
fd18bc0330 | ||
|
|
b499a6df77 | ||
|
|
cabec57631 | ||
|
|
63f7a0685f | ||
|
|
94e6d3f89b | ||
|
|
94ac9c9ea1 | ||
|
|
bbf183bef7 | ||
|
|
6f92188323 | ||
|
|
f0985ff9d9 | ||
|
|
ba3baf3595 | ||
|
|
34c6b416b0 | ||
|
|
bf906a7867 | ||
|
|
5786e2620a | ||
|
|
fe42861bed | ||
|
|
5a96e19ce9 | ||
|
|
8ed0379136 | ||
|
|
4e2f5b1a5b | ||
|
|
317f603262 | ||
|
|
701013baab | ||
|
|
4b3bee6400 | ||
|
|
91868969ca | ||
|
|
ef46b3e8ad | ||
|
|
9e87230102 | ||
|
|
2558e6db79 | ||
|
|
bee570c3cf | ||
|
|
be288d26ca | ||
|
|
b055780984 | ||
|
|
e805a6ff82 | ||
|
|
60335452a4 | ||
|
|
3a822c24e2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
CMakeLists.txt.*
|
||||
build/
|
||||
|
||||
13
CHANGELOG
13
CHANGELOG
@@ -1,3 +1,16 @@
|
||||
2.0 Alpha 5 (2013-12-20)
|
||||
=========================
|
||||
|
||||
- Support copying entries and groups using drag'n'drop [#74]
|
||||
- Open last used databases on startup [#36]
|
||||
- Made the kdbx file parser more robust
|
||||
- Only edit entries on doubleclick (not single) or with enter key
|
||||
- Allow removing multiple entries
|
||||
- Added option to minimize window when copying data to clipboard
|
||||
- Save password generator settings
|
||||
- Fixed auto-type producing wrong chars in some keyboard configurations [#116]
|
||||
- Added some more actions to the toolbar
|
||||
|
||||
2.0 Alpha 4 (2013-03-29)
|
||||
=========================
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are: None Debug Release RelWithDebInfo Debug Debugfull Profile MinSizeRel."
|
||||
FORCE)
|
||||
endif()
|
||||
|
||||
project(KeePassX)
|
||||
|
||||
cmake_minimum_required(VERSION 2.6.4)
|
||||
@@ -28,8 +34,8 @@ option(WITH_GUI_TESTS "Enable building of GUI tests" OFF)
|
||||
option(WITH_LTO "Enable Link Time Optimization (LTO)" OFF)
|
||||
option(WITH_CXX11 "Build with the C++ 11 standard" OFF)
|
||||
|
||||
set(KEEPASSX_VERSION "2.0 alpha 4")
|
||||
set(KEEPASSX_VERSION_NUM "1.9.83")
|
||||
set(KEEPASSX_VERSION "2.0 alpha 5")
|
||||
set(KEEPASSX_VERSION_NUM "1.9.84")
|
||||
|
||||
if("${CMAKE_C_COMPILER}" MATCHES "clang$" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_CLANG 1)
|
||||
@@ -58,14 +64,21 @@ endmacro(add_gcc_compiler_flags)
|
||||
|
||||
add_definitions(-DQT_NO_KEYWORDS -DQT_NO_EXCEPTIONS -DQT_NO_STL -DQT_STRICT_ITERATORS -DQT_NO_CAST_TO_ASCII)
|
||||
|
||||
add_gcc_compiler_flags("-fno-common -fstack-protector -D_FORTIFY_SOURCE=2")
|
||||
add_gcc_compiler_flags("-fno-common -fstack-protector --param=ssp-buffer-size=4")
|
||||
add_gcc_compiler_flags("-Wall -Wextra -Wundef -Wpointer-arith -Wno-long-long")
|
||||
add_gcc_compiler_flags("-Wformat=2 -Wmissing-format-attribute")
|
||||
add_gcc_compiler_flags("-fvisibility=hidden")
|
||||
add_gcc_compiler_cxxflags("-fvisibility-inlines-hidden")
|
||||
|
||||
add_gcc_compiler_cxxflags("-fno-exceptions -fno-rtti")
|
||||
add_gcc_compiler_cxxflags("-Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual")
|
||||
add_gcc_compiler_cflags("-Wchar-subscripts -Wwrite-strings")
|
||||
|
||||
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
|
||||
if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel))
|
||||
add_gcc_compiler_flags("-D_FORTIFY_SOURCE=2")
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag("-Werror=format-security -Werror=implicit-function-declaration" WERROR_C_AVAILABLE)
|
||||
check_cxx_compiler_flag("-Werror=format-security" WERROR_CXX_AVAILABLE)
|
||||
if(WERROR_C_AVAILABLE AND WERROR_CXX_AVAILABLE)
|
||||
@@ -73,16 +86,12 @@ if(WERROR_C_AVAILABLE AND WERROR_CXX_AVAILABLE)
|
||||
add_gcc_compiler_cflags("-Werror=implicit-function-declaration")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_CLANGXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mllvm -stack-protector-buffer-size=4")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align --param=ssp-buffer-size=4")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_CLANG)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mllvm -stack-protector-buffer-size=4")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-align --param=ssp-buffer-size=4")
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wcast-align")
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
@@ -138,9 +147,11 @@ elseif(APPLE)
|
||||
set(PLUGIN_INSTALL_DIR ".")
|
||||
set(DATA_INSTALL_DIR "${PROGNAME}.app/Contents/Resources")
|
||||
else()
|
||||
set(BIN_INSTALL_DIR "bin")
|
||||
set(PLUGIN_INSTALL_DIR "lib/keepassx")
|
||||
set(DATA_INSTALL_DIR "share/keepassx")
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
|
||||
set(PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/keepassx")
|
||||
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/keepassx")
|
||||
endif()
|
||||
|
||||
if(WITH_TESTS)
|
||||
@@ -153,14 +164,7 @@ if(UNIX AND NOT APPLE)
|
||||
endif()
|
||||
|
||||
find_package(Qt4 4.6.0 REQUIRED ${QT_REQUIRED_MODULES})
|
||||
add_definitions(${QT_DEFINITIONS} -DQT_CORE_LIB -DQT_GUI_LIB)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG)
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG)
|
||||
endif()
|
||||
include(${QT_USE_FILE})
|
||||
|
||||
find_package(Gcrypt REQUIRED)
|
||||
|
||||
@@ -201,7 +205,12 @@ if(UNIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories(SYSTEM ${QT_INCLUDE_DIR} ${GCRYPT_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
include_directories(SYSTEM ${GCRYPT_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
if(NOT (${CMAKE_VERSION} VERSION_LESS 2.8.3))
|
||||
set(PRINT_SUMMARY ON)
|
||||
include(FeatureSummary)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(share)
|
||||
@@ -209,3 +218,7 @@ add_subdirectory(utils)
|
||||
if(WITH_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif(WITH_TESTS)
|
||||
|
||||
if(PRINT_SUMMARY)
|
||||
feature_summary(WHAT ALL)
|
||||
endif()
|
||||
|
||||
6
COPYING
6
COPYING
@@ -27,6 +27,11 @@ Copyright: 2010-2012, Felix Geyer <debfx@fobos.de>
|
||||
2000-2008, Tom Sato <VEF00200@nifty.ne.jp>
|
||||
License: GPL-2 or GPL-3
|
||||
|
||||
Files: cmake/GNUInstallDirs.cmake
|
||||
Copyright: 2011 Nikita Krupen'ko <krnekit@gmail.com>
|
||||
2011 Kitware, Inc.
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: share/icons/application/*/apps/keepassx.png
|
||||
share/icons/application/scalable/apps/keepassx.svgz
|
||||
Copyright: 2006, Otto Salminen
|
||||
@@ -122,6 +127,7 @@ Files: share/icons/application/*/actions/application-exit.png
|
||||
share/icons/application/*/actions/dialog-ok.png
|
||||
share/icons/application/*/actions/document-close.png
|
||||
share/icons/application/*/actions/document-edit.png
|
||||
share/icons/application/*/actions/document-encrypt.png
|
||||
share/icons/application/*/actions/document-new.png
|
||||
share/icons/application/*/actions/document-open.png
|
||||
share/icons/application/*/actions/document-save.png
|
||||
|
||||
14
INSTALL
14
INSTALL
@@ -16,15 +16,13 @@ Installing:
|
||||
===========
|
||||
make install [DESTDIR=X]
|
||||
|
||||
Create a bundle on Mac:
|
||||
make package
|
||||
|
||||
Run tests:
|
||||
==========
|
||||
make test [CTEST_OUTPUT_ON_FAILURE=1] [ARGS+=-jX] [ARGS+="-E testgui"]
|
||||
|
||||
Building on Mac OS X:
|
||||
=====================
|
||||
Install macports and cmake
|
||||
Open /opt/local/etc/macports/macports.conf and set the architecture(s) you want to build for.
|
||||
Run: sudo port install qt4-mac libgcrypt zlib
|
||||
If you want to build a universal binary append " +universal" to the above command.
|
||||
Pass -DCMAKE_OSX_ARCHITECTURES="<ARCH1>;<ARCH2>" to cmake
|
||||
Run: make package
|
||||
OS specific instructions:
|
||||
=========================
|
||||
https://www.keepassx.org/dev/projects/keepassx/wiki/Install_instructions
|
||||
|
||||
188
cmake/GNUInstallDirs.cmake
Normal file
188
cmake/GNUInstallDirs.cmake
Normal file
@@ -0,0 +1,188 @@
|
||||
# - Define GNU standard installation directories
|
||||
# Provides install directory variables as defined for GNU software:
|
||||
# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html
|
||||
# Inclusion of this module defines the following variables:
|
||||
# CMAKE_INSTALL_<dir> - destination for files of a given type
|
||||
# CMAKE_INSTALL_FULL_<dir> - corresponding absolute path
|
||||
# where <dir> is one of:
|
||||
# BINDIR - user executables (bin)
|
||||
# SBINDIR - system admin executables (sbin)
|
||||
# LIBEXECDIR - program executables (libexec)
|
||||
# SYSCONFDIR - read-only single-machine data (etc)
|
||||
# SHAREDSTATEDIR - modifiable architecture-independent data (com)
|
||||
# LOCALSTATEDIR - modifiable single-machine data (var)
|
||||
# LIBDIR - object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian)
|
||||
# INCLUDEDIR - C header files (include)
|
||||
# OLDINCLUDEDIR - C header files for non-gcc (/usr/include)
|
||||
# DATAROOTDIR - read-only architecture-independent data root (share)
|
||||
# DATADIR - read-only architecture-independent data (DATAROOTDIR)
|
||||
# INFODIR - info documentation (DATAROOTDIR/info)
|
||||
# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale)
|
||||
# MANDIR - man documentation (DATAROOTDIR/man)
|
||||
# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME)
|
||||
# Each CMAKE_INSTALL_<dir> value may be passed to the DESTINATION options of
|
||||
# install() commands for the corresponding file type. If the includer does
|
||||
# not define a value the above-shown default will be used and the value will
|
||||
# appear in the cache for editing by the user.
|
||||
# Each CMAKE_INSTALL_FULL_<dir> value contains an absolute path constructed
|
||||
# from the corresponding destination by prepending (if necessary) the value
|
||||
# of CMAKE_INSTALL_PREFIX.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2011 Nikita Krupen'ko <krnekit@gmail.com>
|
||||
# Copyright 2011 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Installation directories
|
||||
#
|
||||
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
|
||||
set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_SBINDIR)
|
||||
set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR)
|
||||
set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR)
|
||||
set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR)
|
||||
set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR)
|
||||
set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(_LIBDIR_DEFAULT "lib")
|
||||
# Override this default 'lib' with 'lib64' iff:
|
||||
# - we are on Linux system but NOT cross-compiling
|
||||
# - we are NOT on debian
|
||||
# - we are on a 64 bits system
|
||||
# reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf
|
||||
# For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if
|
||||
# CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu"
|
||||
# See http://wiki.debian.org/Multiarch
|
||||
if((CMAKE_SYSTEM_NAME MATCHES "Linux|kFreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "GNU")
|
||||
AND NOT CMAKE_CROSSCOMPILING)
|
||||
if (EXISTS "/etc/debian_version") # is this a debian system ?
|
||||
if(CMAKE_LIBRARY_ARCHITECTURE)
|
||||
set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
endif()
|
||||
else() # not debian, rely on CMAKE_SIZEOF_VOID_P:
|
||||
if(NOT DEFINED CMAKE_SIZEOF_VOID_P)
|
||||
message(AUTHOR_WARNING
|
||||
"Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. "
|
||||
"Please enable at least one language before including GNUInstallDirs.")
|
||||
else()
|
||||
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
|
||||
set(_LIBDIR_DEFAULT "lib64")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
|
||||
set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR)
|
||||
set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
|
||||
set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Values whose defaults are relative to DATAROOTDIR. Store empty values in
|
||||
# the cache and store the defaults in local variables if the cache values are
|
||||
# not set explicitly. This auto-updates the defaults as DATAROOTDIR changes.
|
||||
|
||||
if(NOT CMAKE_INSTALL_DATADIR)
|
||||
set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)")
|
||||
set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_INFODIR)
|
||||
set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)")
|
||||
set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_LOCALEDIR)
|
||||
set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)")
|
||||
set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_MANDIR)
|
||||
set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)")
|
||||
set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_INSTALL_DOCDIR)
|
||||
set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
|
||||
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
mark_as_advanced(
|
||||
CMAKE_INSTALL_BINDIR
|
||||
CMAKE_INSTALL_SBINDIR
|
||||
CMAKE_INSTALL_LIBEXECDIR
|
||||
CMAKE_INSTALL_SYSCONFDIR
|
||||
CMAKE_INSTALL_SHAREDSTATEDIR
|
||||
CMAKE_INSTALL_LOCALSTATEDIR
|
||||
CMAKE_INSTALL_LIBDIR
|
||||
CMAKE_INSTALL_INCLUDEDIR
|
||||
CMAKE_INSTALL_OLDINCLUDEDIR
|
||||
CMAKE_INSTALL_DATAROOTDIR
|
||||
CMAKE_INSTALL_DATADIR
|
||||
CMAKE_INSTALL_INFODIR
|
||||
CMAKE_INSTALL_LOCALEDIR
|
||||
CMAKE_INSTALL_MANDIR
|
||||
CMAKE_INSTALL_DOCDIR
|
||||
)
|
||||
|
||||
# Result directories
|
||||
#
|
||||
foreach(dir
|
||||
BINDIR
|
||||
SBINDIR
|
||||
LIBEXECDIR
|
||||
SYSCONFDIR
|
||||
SHAREDSTATEDIR
|
||||
LOCALSTATEDIR
|
||||
LIBDIR
|
||||
INCLUDEDIR
|
||||
OLDINCLUDEDIR
|
||||
DATAROOTDIR
|
||||
DATADIR
|
||||
INFODIR
|
||||
LOCALEDIR
|
||||
MANDIR
|
||||
DOCDIR
|
||||
)
|
||||
if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}})
|
||||
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}")
|
||||
else()
|
||||
set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -20,6 +20,7 @@ install(FILES ${DATABASE_ICONS} DESTINATION ${DATA_INSTALL_DIR}/icons/database)
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(DIRECTORY icons/application/ DESTINATION share/icons/hicolor
|
||||
FILES_MATCHING PATTERN "keepassx.png" PATTERN "keepassx.svgz")
|
||||
install(FILES linux/keepassx.desktop DESTINATION share/applications)
|
||||
endif(UNIX AND NOT APPLE)
|
||||
|
||||
if(APPLE)
|
||||
|
||||
BIN
share/icons/application/22x22/actions/document-encrypt.png
Normal file
BIN
share/icons/application/22x22/actions/document-encrypt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 604 B |
12
share/linux/keepassx.desktop
Normal file
12
share/linux/keepassx.desktop
Normal file
@@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Name=KeePassX
|
||||
GenericName=Cross Platform Password Manager
|
||||
GenericName[de]=Passwortverwaltung
|
||||
GenericName[es]=Gestor de contraseñas multiplataforma
|
||||
GenericName[fr]=Gestionnaire de mot de passe
|
||||
Exec=keepassx %f
|
||||
Icon=keepassx
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Qt;Utility;
|
||||
MimeType=application/x-keepass2;
|
||||
@@ -20,11 +20,14 @@ configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepas
|
||||
set(keepassx_SOURCES
|
||||
autotype/AutoType.cpp
|
||||
autotype/AutoTypeAction.cpp
|
||||
autotype/AutoTypePlatformPlugin.h
|
||||
autotype/AutoTypeSelectDialog.cpp
|
||||
autotype/AutoTypeSelectView.cpp
|
||||
autotype/ShortcutWidget.cpp
|
||||
autotype/WildcardMatcher.cpp
|
||||
autotype/WindowSelectComboBox.cpp
|
||||
autotype/test/AutoTypeTestInterface.h
|
||||
core/ArgumentParser.cpp
|
||||
core/AutoTypeAssociations.cpp
|
||||
core/Config.cpp
|
||||
core/Database.cpp
|
||||
@@ -34,11 +37,13 @@ set(keepassx_SOURCES
|
||||
core/EntryAttachments.cpp
|
||||
core/EntryAttributes.cpp
|
||||
core/FilePath.cpp
|
||||
core/Global.h
|
||||
core/Group.cpp
|
||||
core/ListDeleter.h
|
||||
core/Metadata.cpp
|
||||
core/PasswordGenerator.cpp
|
||||
core/qsavefile.cpp
|
||||
core/qsavefile_p.h
|
||||
core/SignalMultiplexer.cpp
|
||||
core/TimeDelta.cpp
|
||||
core/TimeInfo.cpp
|
||||
@@ -82,6 +87,7 @@ set(keepassx_SOURCES
|
||||
gui/KeePass1OpenWidget.cpp
|
||||
gui/LineEdit.cpp
|
||||
gui/MainWindow.cpp
|
||||
gui/MessageBox.cpp
|
||||
gui/PasswordGeneratorWidget.cpp
|
||||
gui/SettingsWidget.cpp
|
||||
gui/SortFilterHideProxyModel.cpp
|
||||
@@ -89,6 +95,7 @@ set(keepassx_SOURCES
|
||||
gui/WelcomeWidget.cpp
|
||||
gui/entry/AutoTypeAssociationsModel.cpp
|
||||
gui/entry/EditEntryWidget.cpp
|
||||
gui/entry/EditEntryWidget_p.h
|
||||
gui/entry/EntryAttachmentsModel.cpp
|
||||
gui/entry/EntryAttributesModel.cpp
|
||||
gui/entry/EntryHistoryModel.cpp
|
||||
@@ -98,6 +105,7 @@ set(keepassx_SOURCES
|
||||
gui/group/GroupModel.cpp
|
||||
gui/group/GroupView.cpp
|
||||
keys/CompositeKey.cpp
|
||||
keys/CompositeKey_p.h
|
||||
keys/FileKey.cpp
|
||||
keys/Key.h
|
||||
keys/PasswordKey.cpp
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "AutoType.h"
|
||||
|
||||
#include <QtCore/QPluginLoader>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QApplication>
|
||||
#include <QPluginLoader>
|
||||
|
||||
#include "autotype/AutoTypePlatformPlugin.h"
|
||||
#include "autotype/AutoTypeSelectDialog.h"
|
||||
@@ -57,11 +57,16 @@ AutoType::AutoType(QObject* parent, bool test)
|
||||
if (!pluginPath.isEmpty()) {
|
||||
loadPlugin(pluginPath);
|
||||
}
|
||||
|
||||
connect(qApp, SIGNAL(aboutToQuit()), SLOT(unloadPlugin()));
|
||||
}
|
||||
|
||||
AutoType::~AutoType()
|
||||
{
|
||||
delete m_executor;
|
||||
if (m_executor) {
|
||||
delete m_executor;
|
||||
m_executor = Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
void AutoType::loadPlugin(const QString& pluginPath)
|
||||
@@ -215,6 +220,19 @@ void AutoType::resetInAutoType()
|
||||
m_inAutoType = false;
|
||||
}
|
||||
|
||||
void AutoType::unloadPlugin()
|
||||
{
|
||||
if (m_executor) {
|
||||
delete m_executor;
|
||||
m_executor = Q_NULLPTR;
|
||||
}
|
||||
|
||||
if (m_plugin) {
|
||||
m_plugin->unload();
|
||||
m_plugin = Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
|
||||
bool AutoType::registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
Q_ASSERT(key);
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef KEEPASSX_AUTOTYPE_H
|
||||
#define KEEPASSX_AUTOTYPE_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
@@ -59,6 +59,7 @@ Q_SIGNALS:
|
||||
private Q_SLOTS:
|
||||
void performAutoTypeFromGlobal(Entry* entry, const QString& sequence);
|
||||
void resetInAutoType();
|
||||
void unloadPlugin();
|
||||
|
||||
private:
|
||||
explicit AutoType(QObject* parent = Q_NULLPTR, bool test = false);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_AUTOTYPEACTION_H
|
||||
#define KEEPASSX_AUTOTYPEACTION_H
|
||||
|
||||
#include <QtCore/QChar>
|
||||
#include <QtCore/Qt>
|
||||
#include <QChar>
|
||||
#include <Qt>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_AUTOTYPEPLATFORMPLUGIN_H
|
||||
#define KEEPASSX_AUTOTYPEPLATFORMPLUGIN_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
#include "autotype/AutoTypeAction.h"
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
virtual void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) = 0;
|
||||
virtual int platformEventFilter(void* event) = 0;
|
||||
virtual int initialTimeout() = 0;
|
||||
virtual void unload() {}
|
||||
|
||||
virtual AutoTypeExecutor* createExecutor() = 0;
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
#include "AutoTypeSelectDialog.h"
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QDesktopWidget>
|
||||
#include <QtGui/QDialogButtonBox>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "autotype/AutoTypeSelectView.h"
|
||||
#include "core/FilePath.h"
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef KEEPASSX_AUTOTYPESELECTDIALOG_H
|
||||
#define KEEPASSX_AUTOTYPESELECTDIALOG_H
|
||||
|
||||
#include <QtCore/QAbstractItemModel>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QDialog>
|
||||
#include <QHash>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "AutoTypeSelectView.h"
|
||||
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
AutoTypeSelectView::AutoTypeSelectView(QWidget* parent)
|
||||
: EntryView(parent)
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
if(Q_WS_X11)
|
||||
find_package(X11)
|
||||
if(PRINT_SUMMARY)
|
||||
add_feature_info(libXtest X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type")
|
||||
endif()
|
||||
|
||||
if(X11_FOUND AND X11_XTest_FOUND)
|
||||
add_subdirectory(x11)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "ShortcutWidget.h"
|
||||
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_SHORTCUTWIDGET_H
|
||||
#define KEEPASSX_SHORTCUTWIDGET_H
|
||||
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "WildcardMatcher.h"
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QStringList>
|
||||
|
||||
const QChar WildcardMatcher::Wildcard = '*';
|
||||
const Qt::CaseSensitivity WildcardMatcher::Sensitivity = Qt::CaseInsensitive;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_WILDCARDMATCHER_H
|
||||
#define KEEPASSX_WILDCARDMATCHER_H
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
#include <QStringList>
|
||||
|
||||
class WildcardMatcher
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "WindowSelectComboBox.h"
|
||||
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_WINDOWSELECTCOMBOBOX_H
|
||||
#define KEEPASSX_WINDOWSELECTCOMBOBOX_H
|
||||
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_AUTOTYPETEST_H
|
||||
#define KEEPASSX_AUTOTYPETEST_H
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include "autotype/AutoTypePlatformPlugin.h"
|
||||
#include "autotype/AutoTypeAction.h"
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "AutoTypeX11.h"
|
||||
#include "KeySymMap.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
bool AutoTypePlatformX11::m_catchXErrors = false;
|
||||
bool AutoTypePlatformX11::m_xErrorOccured = false;
|
||||
@@ -42,14 +45,31 @@ AutoTypePlatformX11::AutoTypePlatformX11()
|
||||
m_currentGlobalModifiers = 0;
|
||||
|
||||
m_keysymTable = Q_NULLPTR;
|
||||
m_altMask = 0;
|
||||
m_metaMask = 0;
|
||||
m_altgrMask = 0;
|
||||
m_altgrKeysym = NoSymbol;
|
||||
m_xkb = Q_NULLPTR;
|
||||
m_specialCharacterKeycode = 0;
|
||||
m_modifierMask = ControlMask | ShiftMask | Mod1Mask | Mod4Mask;
|
||||
|
||||
m_loaded = true;
|
||||
|
||||
updateKeymap();
|
||||
}
|
||||
|
||||
void AutoTypePlatformX11::unload()
|
||||
{
|
||||
// Restore the KeyboardMapping to its original state.
|
||||
AddKeysym(NoSymbol);
|
||||
|
||||
if (m_keysymTable) {
|
||||
XFree(m_keysymTable);
|
||||
}
|
||||
|
||||
if (m_xkb) {
|
||||
XkbFreeKeyboard(m_xkb, XkbAllComponentsMask, True);
|
||||
}
|
||||
|
||||
m_loaded = false;
|
||||
}
|
||||
|
||||
QStringList AutoTypePlatformX11::windowTitles()
|
||||
{
|
||||
return windowTitlesRecursive(m_rootWindow);
|
||||
@@ -125,10 +145,10 @@ uint AutoTypePlatformX11::qtToNativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
nativeModifiers |= ControlMask;
|
||||
}
|
||||
if (modifiers & Qt::AltModifier) {
|
||||
nativeModifiers |= m_altMask;
|
||||
nativeModifiers |= Mod1Mask;
|
||||
}
|
||||
if (modifiers & Qt::MetaModifier) {
|
||||
nativeModifiers |= m_metaMask;
|
||||
nativeModifiers |= Mod4Mask;
|
||||
}
|
||||
|
||||
return nativeModifiers;
|
||||
@@ -158,13 +178,15 @@ int AutoTypePlatformX11::platformEventFilter(void* event)
|
||||
&& m_currentGlobalKey
|
||||
&& xevent->xkey.keycode == m_currentGlobalKeycode
|
||||
&& (xevent->xkey.state & m_modifierMask) == m_currentGlobalNativeModifiers
|
||||
&& !QApplication::focusWidget()) {
|
||||
&& !QApplication::focusWidget()
|
||||
&& m_loaded) {
|
||||
if (xevent->type == KeyPress) {
|
||||
Q_EMIT globalShortcutTriggered();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (xevent->type == MappingNotify) {
|
||||
if (xevent->type == MappingNotify && m_loaded) {
|
||||
XRefreshKeyboardMapping(reinterpret_cast<XMappingEvent*>(xevent));
|
||||
updateKeymap();
|
||||
}
|
||||
|
||||
@@ -326,12 +348,21 @@ KeySym AutoTypePlatformX11::charToKeySym(const QChar& ch)
|
||||
|| (unicode >= 0x00a0 && unicode <= 0x00ff)) {
|
||||
return unicode;
|
||||
}
|
||||
else if (unicode >= 0x0100) {
|
||||
|
||||
/* mapping table generated from keysymdef.h */
|
||||
const uint* match = qBinaryFind(m_unicodeToKeysymKeys,
|
||||
m_unicodeToKeysymKeys + m_unicodeToKeysymLen,
|
||||
unicode);
|
||||
int index = match - m_unicodeToKeysymKeys;
|
||||
if (index != m_unicodeToKeysymLen) {
|
||||
return m_unicodeToKeysymValues[index];
|
||||
}
|
||||
|
||||
if (unicode >= 0x0100) {
|
||||
return unicode | 0x01000000;
|
||||
}
|
||||
else {
|
||||
return NoSymbol;
|
||||
}
|
||||
|
||||
return NoSymbol;
|
||||
}
|
||||
|
||||
KeySym AutoTypePlatformX11::keyToKeySym(Qt::Key key)
|
||||
@@ -387,24 +418,51 @@ KeySym AutoTypePlatformX11::keyToKeySym(Qt::Key key)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the keyboard and modifier mapping.
|
||||
* We need the KeyboardMapping for AddKeysym.
|
||||
* Modifier mapping is required for clearing the modifiers.
|
||||
*/
|
||||
void AutoTypePlatformX11::updateKeymap()
|
||||
{
|
||||
ReadKeymap();
|
||||
int keycode, inx;
|
||||
int mod_index, mod_key;
|
||||
XModifierKeymap *modifiers;
|
||||
|
||||
if (!m_altgrMask) {
|
||||
AddModifier(XK_Mode_switch);
|
||||
}
|
||||
if (!m_metaMask) {
|
||||
m_metaMask = Mod4Mask;
|
||||
/* read keyboard map */
|
||||
if (m_xkb != NULL) XkbFreeKeyboard(m_xkb, XkbAllComponentsMask, True);
|
||||
m_xkb = XkbGetKeyboard (m_dpy, XkbCompatMapMask | XkbGeometryMask, XkbUseCoreKbd);
|
||||
|
||||
XDisplayKeycodes(m_dpy, &m_minKeycode, &m_maxKeycode);
|
||||
if (m_keysymTable != NULL) XFree(m_keysymTable);
|
||||
m_keysymTable = XGetKeyboardMapping(m_dpy,
|
||||
m_minKeycode, m_maxKeycode - m_minKeycode + 1,
|
||||
&m_keysymPerKeycode);
|
||||
|
||||
/* determine the keycode to use for remapped keys */
|
||||
if (m_specialCharacterKeycode == 0) {
|
||||
for (keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) {
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_keysymTable[inx] == NoSymbol) {
|
||||
m_specialCharacterKeycode = keycode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_modifierMask = ControlMask | ShiftMask | m_altMask | m_metaMask;
|
||||
|
||||
// TODO: figure out why this breaks after the first global auto-type
|
||||
/*if (m_currentGlobalKey && m_currentGlobalModifiers) {
|
||||
unregisterGlobalShortcut(m_currentGlobalKey, m_currentGlobalModifiers);
|
||||
registerGlobalShortcut(m_currentGlobalKey, m_currentGlobalModifiers);
|
||||
}*/
|
||||
/* determine the keycode to use for modifiers */
|
||||
modifiers = XGetModifierMapping(m_dpy);
|
||||
for (mod_index = ShiftMapIndex; mod_index <= Mod5MapIndex; mod_index ++) {
|
||||
m_modifier_keycode[mod_index] = 0;
|
||||
for (mod_key = 0; mod_key < modifiers->max_keypermod; mod_key++) {
|
||||
keycode = modifiers->modifiermap[mod_index * modifiers->max_keypermod + mod_key];
|
||||
if (keycode) {
|
||||
m_modifier_keycode[mod_index] = keycode;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
XFreeModifiermap(modifiers);
|
||||
}
|
||||
|
||||
void AutoTypePlatformX11::startCatchXErrors()
|
||||
@@ -442,141 +500,28 @@ int AutoTypePlatformX11::x11ErrorHandler(Display* display, XErrorEvent* error)
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* Insert a specified keysym to unused position in the keymap table.
|
||||
* This will be called to add required keysyms on-the-fly.
|
||||
* if the second parameter is TRUE, the keysym will be added to the
|
||||
* non-shifted position - this may be required for modifier keys
|
||||
* (e.g. Mode_switch) and some special keys (e.g. F20).
|
||||
* Insert a specified keysym on the dedicated position in the keymap
|
||||
* table.
|
||||
*/
|
||||
int AutoTypePlatformX11::AddKeysym(KeySym keysym, bool top)
|
||||
int AutoTypePlatformX11::AddKeysym(KeySym keysym)
|
||||
{
|
||||
int keycode, pos, max_pos, inx, phase;
|
||||
|
||||
if (top) {
|
||||
max_pos = 0;
|
||||
} else {
|
||||
max_pos = m_keysymPerKeycode - 1;
|
||||
if (4 <= max_pos) max_pos = 3;
|
||||
if (2 <= max_pos && m_altgrKeysym != XK_Mode_switch) max_pos = 1;
|
||||
if (m_specialCharacterKeycode == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (phase = 0; phase < 2; phase++) {
|
||||
for (keycode = m_maxKeycode; m_minKeycode <= keycode; keycode--) {
|
||||
for (pos = max_pos; 0 <= pos; pos--) {
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if ((phase != 0 || m_keysymTable[inx] == NoSymbol) && m_keysymTable[inx] < 0xFF00) {
|
||||
/* In the first phase, to avoid modifing existing keys, */
|
||||
/* add the keysym only to the keys which has no keysym in the first position. */
|
||||
/* If no place fuond in the first phase, add the keysym for any keys except */
|
||||
/* for modifier keys and other special keys */
|
||||
if (m_keysymTable[inx + pos] == NoSymbol) {
|
||||
m_keysymTable[inx + pos] = keysym;
|
||||
XChangeKeyboardMapping(m_dpy, keycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
|
||||
XFlush(m_dpy);
|
||||
return keycode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
qWarning("Couldn't add \"%s\" to keymap", XKeysymToString(keysym));
|
||||
return NoSymbol;
|
||||
}
|
||||
int inx = (m_specialCharacterKeycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
m_keysymTable[inx] = keysym;
|
||||
XChangeKeyboardMapping(m_dpy, m_specialCharacterKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
|
||||
XFlush(m_dpy);
|
||||
|
||||
/*
|
||||
* Add the specified key as a new modifier.
|
||||
* This is used to use Mode_switch (AltGr) as a modifier.
|
||||
*/
|
||||
void AutoTypePlatformX11::AddModifier(KeySym keysym)
|
||||
{
|
||||
XModifierKeymap *modifiers;
|
||||
int keycode, i, pos;
|
||||
/* Xlib needs some time until the mapping is distributed to
|
||||
all clients */
|
||||
timespec ts;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 10 * 1000 * 1000;
|
||||
nanosleep(&ts, Q_NULLPTR);
|
||||
|
||||
keycode = XKeysymToKeycode(m_dpy, keysym);
|
||||
if (keycode == NoSymbol) keycode = AddKeysym(keysym, TRUE);
|
||||
|
||||
modifiers = XGetModifierMapping(m_dpy);
|
||||
for (i = 7; 3 < i; i--) {
|
||||
if (modifiers->modifiermap[i * modifiers->max_keypermod] == NoSymbol
|
||||
|| ((m_keysymTable[(modifiers->modifiermap[i * modifiers->max_keypermod]
|
||||
- m_minKeycode) * m_keysymPerKeycode]) == XK_ISO_Level3_Shift
|
||||
&& keysym == XK_Mode_switch))
|
||||
{
|
||||
for (pos = 0; pos < modifiers->max_keypermod; pos++) {
|
||||
if (modifiers->modifiermap[i * modifiers->max_keypermod + pos] == NoSymbol) {
|
||||
modifiers->modifiermap[i * modifiers->max_keypermod + pos] = keycode;
|
||||
XSetModifierMapping(m_dpy, modifiers);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
qWarning("Couldn't add \"%s\" as modifier", XKeysymToString(keysym));
|
||||
}
|
||||
|
||||
/*
|
||||
* Read keyboard mapping and modifier mapping.
|
||||
* Keyboard mapping is used to know what keys are in shifted position.
|
||||
* Modifier mapping is required because we should know Alt and Meta
|
||||
* key are used as which modifier.
|
||||
*/
|
||||
void AutoTypePlatformX11::ReadKeymap()
|
||||
{
|
||||
int i;
|
||||
int keycode, inx, pos;
|
||||
KeySym keysym;
|
||||
XModifierKeymap *modifiers;
|
||||
|
||||
XDisplayKeycodes(m_dpy, &m_minKeycode, &m_maxKeycode);
|
||||
if (m_keysymTable != NULL) XFree(m_keysymTable);
|
||||
m_keysymTable = XGetKeyboardMapping(m_dpy,
|
||||
m_minKeycode, m_maxKeycode - m_minKeycode + 1,
|
||||
&m_keysymPerKeycode);
|
||||
for (keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) {
|
||||
/* if the first keysym is alphabet and the second keysym is NoSymbol,
|
||||
it is equivalent to pair of lowercase and uppercase alphabet */
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_keysymTable[inx + 1] == NoSymbol
|
||||
&& ((XK_A <= m_keysymTable[inx] && m_keysymTable[inx] <= XK_Z)
|
||||
|| (XK_a <= m_keysymTable[inx] && m_keysymTable[inx] <= XK_z)))
|
||||
{
|
||||
if (XK_A <= m_keysymTable[inx] && m_keysymTable[inx] <= XK_Z)
|
||||
m_keysymTable[inx] = m_keysymTable[inx] - XK_A + XK_a;
|
||||
m_keysymTable[inx + 1] = m_keysymTable[inx] - XK_a + XK_A;
|
||||
}
|
||||
}
|
||||
|
||||
m_altMask = 0;
|
||||
m_metaMask = 0;
|
||||
m_altgrMask = 0;
|
||||
m_altgrKeysym = NoSymbol;
|
||||
modifiers = XGetModifierMapping(m_dpy);
|
||||
for (i = 0; i < 8; i++) {
|
||||
for (pos = 0; pos < modifiers->max_keypermod; pos++) {
|
||||
keycode = modifiers->modifiermap[i * modifiers->max_keypermod + pos];
|
||||
if (keycode < m_minKeycode || m_maxKeycode < keycode) continue;
|
||||
|
||||
keysym = m_keysymTable[(keycode - m_minKeycode) * m_keysymPerKeycode];
|
||||
if (keysym == XK_Alt_L || keysym == XK_Alt_R) {
|
||||
m_altMask = 1 << i;
|
||||
} else if (keysym == XK_Meta_L || keysym == XK_Meta_R) {
|
||||
m_metaMask = 1 << i;
|
||||
} else if (keysym == XK_Mode_switch) {
|
||||
if (m_altgrKeysym == XK_ISO_Level3_Shift) {
|
||||
} else {
|
||||
m_altgrMask = 0x0101 << i;
|
||||
/* I don't know why, but 0x2000 was required for mod3 on my Linux box */
|
||||
m_altgrKeysym = keysym;
|
||||
}
|
||||
} else if (keysym == XK_ISO_Level3_Shift) {
|
||||
/* if no Mode_switch, try to use ISO_Level3_Shift instead */
|
||||
/* however, it may not work as intended - I don't know why */
|
||||
m_altgrMask = 1 << i;
|
||||
m_altgrKeysym = keysym;
|
||||
}
|
||||
}
|
||||
}
|
||||
XFreeModifiermap(modifiers);
|
||||
return m_specialCharacterKeycode;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -584,78 +529,84 @@ void AutoTypePlatformX11::ReadKeymap()
|
||||
* If input focus is specified explicitly, select the window
|
||||
* before send event to the window.
|
||||
*/
|
||||
void AutoTypePlatformX11::SendEvent(XKeyEvent* event)
|
||||
void AutoTypePlatformX11::SendEvent(XKeyEvent* event, int event_type)
|
||||
{
|
||||
XSync(event->display, FALSE);
|
||||
int (*oldHandler) (Display*, XErrorEvent*) = XSetErrorHandler(MyErrorHandler);
|
||||
|
||||
event->type = event_type;
|
||||
XTestFakeKeyEvent(event->display, event->keycode, event->type == KeyPress, 0);
|
||||
XFlush(event->display);
|
||||
|
||||
XSetErrorHandler(oldHandler);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a modifier press/release event for all modifiers
|
||||
* which are set in the mask variable.
|
||||
*/
|
||||
void AutoTypePlatformX11::SendModifier(XKeyEvent *event, unsigned int mask, int event_type)
|
||||
{
|
||||
int mod_index;
|
||||
for (mod_index = ShiftMapIndex; mod_index <= Mod5MapIndex; mod_index ++) {
|
||||
if (mask & (1 << mod_index)) {
|
||||
event->keycode = m_modifier_keycode[mod_index];
|
||||
SendEvent(event, event_type);
|
||||
if (event_type == KeyPress)
|
||||
event->state |= (1 << mod_index);
|
||||
else
|
||||
event->state &= (1 << mod_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines the keycode and modifier mask for the given
|
||||
* keysym.
|
||||
*/
|
||||
int AutoTypePlatformX11::GetKeycode(KeySym keysym, unsigned int *mask)
|
||||
{
|
||||
int shift, mod;
|
||||
unsigned int mods_rtrn;
|
||||
KeySym keysym_rtrn;
|
||||
int keycode;
|
||||
|
||||
keycode = XKeysymToKeycode(m_dpy, keysym);
|
||||
|
||||
/* determine whether there is a combination of the modifiers
|
||||
(Mod1-Mod5) with or without shift which returns keysym */
|
||||
for (shift = 0; shift < 2; shift ++) {
|
||||
for (mod = ControlMapIndex; mod <= Mod5MapIndex; mod ++) {
|
||||
*mask = (mod == ControlMapIndex) ? shift : shift | (1 << mod);
|
||||
XkbTranslateKeyCode(m_xkb, keycode, *mask, &mods_rtrn, &keysym_rtrn);
|
||||
if (keysym_rtrn == keysym) {
|
||||
return keycode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no modifier matches => resort to remapping */
|
||||
*mask = 0;
|
||||
return AddKeysym(keysym);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Send sequence of KeyPressed/KeyReleased events to the focused
|
||||
* window to simulate keyboard. If modifiers (shift, control, etc)
|
||||
* are set ON, many events will be sent.
|
||||
*/
|
||||
void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
|
||||
void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym)
|
||||
{
|
||||
Window cur_focus;
|
||||
int revert_to;
|
||||
XKeyEvent event;
|
||||
int keycode;
|
||||
int phase, inx;
|
||||
bool found;
|
||||
|
||||
XGetInputFocus(m_dpy, &cur_focus, &revert_to);
|
||||
|
||||
found = FALSE;
|
||||
keycode = 0;
|
||||
if (keysym != NoSymbol) {
|
||||
for (phase = 0; phase < 2; phase++) {
|
||||
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
|
||||
/* Determine keycode for the keysym: we use this instead
|
||||
of XKeysymToKeycode() because we must know shift_state, too */
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_keysymTable[inx] == keysym) {
|
||||
shift &= ~m_altgrMask;
|
||||
if (m_keysymTable[inx + 1] != NoSymbol) shift &= ~ShiftMask;
|
||||
found = TRUE;
|
||||
break;
|
||||
} else if (m_keysymTable[inx + 1] == keysym) {
|
||||
shift &= ~m_altgrMask;
|
||||
shift |= ShiftMask;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found && m_altgrMask && 3 <= m_keysymPerKeycode) {
|
||||
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_keysymTable[inx + 2] == keysym) {
|
||||
shift &= ~ShiftMask;
|
||||
shift |= m_altgrMask;
|
||||
found = TRUE;
|
||||
break;
|
||||
} else if (4 <= m_keysymPerKeycode && m_keysymTable[inx + 3] == keysym) {
|
||||
shift |= ShiftMask | m_altgrMask;
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
|
||||
if (0xF000 <= keysym) {
|
||||
/* for special keys such as function keys,
|
||||
first try to add it in the non-shifted position of the keymap */
|
||||
if (AddKeysym(keysym, TRUE) == NoSymbol) AddKeysym(keysym, FALSE);
|
||||
} else {
|
||||
AddKeysym(keysym, FALSE);
|
||||
}
|
||||
}
|
||||
if (keysym == NoSymbol) {
|
||||
qWarning("No such key: keysym=0x%lX", static_cast<long>(keysym));
|
||||
return;
|
||||
}
|
||||
|
||||
event.display = m_dpy;
|
||||
@@ -672,106 +623,34 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
|
||||
Window root, child;
|
||||
int root_x, root_y, x, y;
|
||||
unsigned int mask;
|
||||
unsigned int saved_mask;
|
||||
|
||||
XQueryPointer(m_dpy, event.root, &root, &child, &root_x, &root_y, &x, &y, &mask);
|
||||
saved_mask = mask;
|
||||
XGetInputFocus(m_dpy, &cur_focus, &revert_to);
|
||||
|
||||
event.type = KeyRelease;
|
||||
event.state = 0;
|
||||
if (mask & ControlMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Control_L);
|
||||
SendEvent(&event);
|
||||
}
|
||||
if (mask & m_altMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Alt_L);
|
||||
SendEvent(&event);
|
||||
}
|
||||
if (mask & m_metaMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Meta_L);
|
||||
SendEvent(&event);
|
||||
}
|
||||
if (mask & m_altgrMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, m_altgrKeysym);
|
||||
SendEvent(&event);
|
||||
}
|
||||
if (mask & ShiftMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Shift_L);
|
||||
SendEvent(&event);
|
||||
}
|
||||
if (mask & LockMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Caps_Lock);
|
||||
SendEvent(&event);
|
||||
/* determine keycode and mask for the given keysym */
|
||||
keycode = GetKeycode(keysym, &mask);
|
||||
if (keycode < 8 || keycode > 255) {
|
||||
qWarning("Unable to get valid keycode for key: keysym=0x%lX", static_cast<long>(keysym));
|
||||
return;
|
||||
}
|
||||
|
||||
event.type = KeyPress;
|
||||
event.state = 0;
|
||||
if (shift & ControlMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Control_L);
|
||||
SendEvent(&event);
|
||||
event.state |= ControlMask;
|
||||
}
|
||||
if (shift & m_altMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Alt_L);
|
||||
SendEvent(&event);
|
||||
event.state |= m_altMask;
|
||||
}
|
||||
if (shift & m_metaMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Meta_L);
|
||||
SendEvent(&event);
|
||||
event.state |= m_metaMask;
|
||||
}
|
||||
if (shift & m_altgrMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, m_altgrKeysym);
|
||||
SendEvent(&event);
|
||||
event.state |= m_altgrMask;
|
||||
}
|
||||
if (shift & ShiftMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Shift_L);
|
||||
SendEvent(&event);
|
||||
event.state |= ShiftMask;
|
||||
}
|
||||
/* release all modifiers */
|
||||
SendModifier(&event, mask, KeyRelease);
|
||||
|
||||
if (keysym != NoSymbol) { /* send event for the key itself */
|
||||
event.keycode = found ? keycode : XKeysymToKeycode(m_dpy, keysym);
|
||||
if (event.keycode == NoSymbol) {
|
||||
if ((keysym & ~0x7f) == 0 && QChar(static_cast<char>(keysym)).isPrint())
|
||||
qWarning("No such key: %c", static_cast<char>(keysym));
|
||||
else if (XKeysymToString(keysym) != NULL)
|
||||
qWarning("No such key: keysym=%s (0x%lX)", XKeysymToString(keysym), static_cast<long>(keysym));
|
||||
else
|
||||
qWarning("No such key: keysym=0x%lX", static_cast<long>(keysym));
|
||||
} else {
|
||||
SendEvent(&event);
|
||||
event.type = KeyRelease;
|
||||
SendEvent(&event);
|
||||
}
|
||||
}
|
||||
SendModifier(&event, mask, KeyPress);
|
||||
|
||||
event.type = KeyRelease;
|
||||
if (shift & ShiftMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Shift_L);
|
||||
SendEvent(&event);
|
||||
event.state &= ~ShiftMask;
|
||||
}
|
||||
if (shift & m_altgrMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, m_altgrKeysym);
|
||||
SendEvent(&event);
|
||||
event.state &= ~m_altgrMask;
|
||||
}
|
||||
if (shift & m_metaMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Meta_L);
|
||||
SendEvent(&event);
|
||||
event.state &= ~m_metaMask;
|
||||
}
|
||||
if (shift & m_altMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Alt_L);
|
||||
SendEvent(&event);
|
||||
event.state &= ~m_altMask;
|
||||
}
|
||||
if (shift & ControlMask) {
|
||||
event.keycode = XKeysymToKeycode(m_dpy, XK_Control_L);
|
||||
SendEvent(&event);
|
||||
event.state &= ~ControlMask;
|
||||
}
|
||||
/* press and release key */
|
||||
event.keycode = keycode;
|
||||
SendEvent(&event, KeyPress);
|
||||
SendEvent(&event, KeyRelease);
|
||||
|
||||
/* release the modifiers */
|
||||
SendModifier(&event, mask, KeyRelease);
|
||||
|
||||
/* restore the old keyboard mask */
|
||||
SendModifier(&event, saved_mask, KeyPress);
|
||||
}
|
||||
|
||||
int AutoTypePlatformX11::MyErrorHandler(Display* my_dpy, XErrorEvent* event)
|
||||
|
||||
@@ -19,19 +19,22 @@
|
||||
#ifndef KEEPASSX_AUTOTYPEX11_H
|
||||
#define KEEPASSX_AUTOTYPEX11_H
|
||||
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QX11Info>
|
||||
#include <QApplication>
|
||||
#include <QSet>
|
||||
#include <QtPlugin>
|
||||
#include <QWidget>
|
||||
#include <QX11Info>
|
||||
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XTest.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
#include "autotype/AutoTypePlatformPlugin.h"
|
||||
#include "autotype/AutoTypeAction.h"
|
||||
#include "core/Global.h"
|
||||
|
||||
#define N_MOD_INDICES (Mod5MapIndex + 1)
|
||||
|
||||
class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -39,6 +42,7 @@ class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
|
||||
|
||||
public:
|
||||
AutoTypePlatformX11();
|
||||
void unload() Q_DECL_OVERRIDE;
|
||||
QStringList windowTitles();
|
||||
WId activeWindow();
|
||||
QString activeWindowTitle();
|
||||
@@ -51,7 +55,7 @@ public:
|
||||
KeySym charToKeySym(const QChar& ch);
|
||||
KeySym keyToKeySym(Qt::Key key);
|
||||
|
||||
void SendKeyPressedEvent(KeySym keysym, unsigned int shift = 0);
|
||||
void SendKeyPressedEvent(KeySym keysym);
|
||||
|
||||
Q_SIGNALS:
|
||||
void globalShortcutTriggered();
|
||||
@@ -68,10 +72,12 @@ private:
|
||||
static int x11ErrorHandler(Display* display, XErrorEvent* error);
|
||||
|
||||
void updateKeymap();
|
||||
int AddKeysym(KeySym keysym, bool top);
|
||||
int AddKeysym(KeySym keysym);
|
||||
void AddModifier(KeySym keysym);
|
||||
void ReadKeymap();
|
||||
void SendEvent(XKeyEvent* event);
|
||||
void SendEvent(XKeyEvent* event, int event_type);
|
||||
void SendModifier(XKeyEvent *event, unsigned int mask, int event_type);
|
||||
int GetKeycode(KeySym keysym, unsigned int *mask);
|
||||
|
||||
static int MyErrorHandler(Display* my_dpy, XErrorEvent* event);
|
||||
|
||||
Display* m_dpy;
|
||||
@@ -91,14 +97,19 @@ private:
|
||||
static bool m_xErrorOccured;
|
||||
static int (*m_oldXErrorHandler)(Display*, XErrorEvent*);
|
||||
|
||||
static const int m_unicodeToKeysymLen;
|
||||
static const uint m_unicodeToKeysymKeys[];
|
||||
static const uint m_unicodeToKeysymValues[];
|
||||
|
||||
XkbDescPtr m_xkb;
|
||||
KeySym* m_keysymTable;
|
||||
int m_minKeycode;
|
||||
int m_maxKeycode;
|
||||
int m_keysymPerKeycode;
|
||||
int m_altMask;
|
||||
int m_metaMask;
|
||||
int m_altgrMask;
|
||||
KeySym m_altgrKeysym;
|
||||
/* dedicated 'special character' keycode */
|
||||
int m_specialCharacterKeycode;
|
||||
KeyCode m_modifier_keycode[N_MOD_INDICES];
|
||||
bool m_loaded;
|
||||
};
|
||||
|
||||
class AutoTypeExecturorX11 : public AutoTypeExecutor
|
||||
|
||||
169
src/autotype/x11/KeySymMap.h
Normal file
169
src/autotype/x11/KeySymMap.h
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Automatically generated by keysymmap.py from parsing keysymdef.h.
|
||||
*/
|
||||
|
||||
const int AutoTypePlatformX11::m_unicodeToKeysymLen = 632;
|
||||
|
||||
const uint AutoTypePlatformX11::m_unicodeToKeysymKeys[] = {
|
||||
0x0100, 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0x0106, 0x0107,
|
||||
0x0108, 0x0109, 0x010a, 0x010b, 0x010c, 0x010d, 0x010e, 0x010f,
|
||||
0x0110, 0x0111, 0x0112, 0x0113, 0x0116, 0x0117, 0x0118, 0x0119,
|
||||
0x011a, 0x011b, 0x011c, 0x011d, 0x011e, 0x011f, 0x0120, 0x0121,
|
||||
0x0122, 0x0123, 0x0124, 0x0125, 0x0126, 0x0127, 0x0128, 0x0129,
|
||||
0x012a, 0x012b, 0x012e, 0x012f, 0x0130, 0x0131, 0x0134, 0x0135,
|
||||
0x0136, 0x0137, 0x0138, 0x0139, 0x013a, 0x013b, 0x013c, 0x013d,
|
||||
0x013e, 0x0141, 0x0142, 0x0143, 0x0144, 0x0145, 0x0146, 0x0147,
|
||||
0x0148, 0x014a, 0x014b, 0x014c, 0x014d, 0x0150, 0x0151, 0x0152,
|
||||
0x0153, 0x0154, 0x0155, 0x0156, 0x0157, 0x0158, 0x0159, 0x015a,
|
||||
0x015b, 0x015c, 0x015d, 0x015e, 0x015f, 0x0160, 0x0161, 0x0162,
|
||||
0x0163, 0x0164, 0x0165, 0x0166, 0x0167, 0x0168, 0x0169, 0x016a,
|
||||
0x016b, 0x016c, 0x016d, 0x016e, 0x016f, 0x0170, 0x0171, 0x0172,
|
||||
0x0173, 0x0178, 0x0179, 0x017a, 0x017b, 0x017c, 0x017d, 0x017e,
|
||||
0x0192, 0x02c7, 0x02d8, 0x02d9, 0x02db, 0x02dd, 0x0385, 0x0386,
|
||||
0x0388, 0x0389, 0x038a, 0x038c, 0x038e, 0x038f, 0x0390, 0x0391,
|
||||
0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399,
|
||||
0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, 0x03a0, 0x03a1,
|
||||
0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, 0x03a8, 0x03a9, 0x03aa,
|
||||
0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03b0, 0x03b1, 0x03b2,
|
||||
0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba,
|
||||
0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c2,
|
||||
0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x03ca,
|
||||
0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0401, 0x0402, 0x0403, 0x0404,
|
||||
0x0405, 0x0406, 0x0407, 0x0408, 0x0409, 0x040a, 0x040b, 0x040c,
|
||||
0x040e, 0x040f, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415,
|
||||
0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d,
|
||||
0x041e, 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425,
|
||||
0x0426, 0x0427, 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d,
|
||||
0x042e, 0x042f, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435,
|
||||
0x0436, 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d,
|
||||
0x043e, 0x043f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445,
|
||||
0x0446, 0x0447, 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d,
|
||||
0x044e, 0x044f, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456,
|
||||
0x0457, 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x045e, 0x045f,
|
||||
0x0490, 0x0491, 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5,
|
||||
0x05d6, 0x05d7, 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd,
|
||||
0x05de, 0x05df, 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5,
|
||||
0x05e6, 0x05e7, 0x05e8, 0x05e9, 0x05ea, 0x060c, 0x061b, 0x061f,
|
||||
0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628,
|
||||
0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, 0x0630,
|
||||
0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638,
|
||||
0x0639, 0x063a, 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645,
|
||||
0x0646, 0x0647, 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d,
|
||||
0x064e, 0x064f, 0x0650, 0x0651, 0x0652, 0x0e01, 0x0e02, 0x0e03,
|
||||
0x0e04, 0x0e05, 0x0e06, 0x0e07, 0x0e08, 0x0e09, 0x0e0a, 0x0e0b,
|
||||
0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, 0x0e10, 0x0e11, 0x0e12, 0x0e13,
|
||||
0x0e14, 0x0e15, 0x0e16, 0x0e17, 0x0e18, 0x0e19, 0x0e1a, 0x0e1b,
|
||||
0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, 0x0e20, 0x0e21, 0x0e22, 0x0e23,
|
||||
0x0e24, 0x0e25, 0x0e26, 0x0e27, 0x0e28, 0x0e29, 0x0e2a, 0x0e2b,
|
||||
0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, 0x0e30, 0x0e31, 0x0e32, 0x0e33,
|
||||
0x0e34, 0x0e35, 0x0e36, 0x0e37, 0x0e38, 0x0e39, 0x0e3a, 0x0e3f,
|
||||
0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
|
||||
0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e50, 0x0e51,
|
||||
0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, 0x0e58, 0x0e59,
|
||||
0x2002, 0x2003, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009, 0x200a,
|
||||
0x2012, 0x2013, 0x2014, 0x2015, 0x2017, 0x2018, 0x2019, 0x201a,
|
||||
0x201c, 0x201d, 0x201e, 0x2020, 0x2021, 0x2025, 0x2026, 0x2030,
|
||||
0x2032, 0x2033, 0x2038, 0x203e, 0x20ac, 0x2105, 0x2116, 0x2117,
|
||||
0x211e, 0x2122, 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158,
|
||||
0x2159, 0x215a, 0x215b, 0x215c, 0x215d, 0x215e, 0x2190, 0x2191,
|
||||
0x2192, 0x2193, 0x21d2, 0x21d4, 0x2202, 0x2207, 0x2218, 0x221a,
|
||||
0x221d, 0x221e, 0x2227, 0x2228, 0x2229, 0x222a, 0x222b, 0x2234,
|
||||
0x223c, 0x2243, 0x2260, 0x2261, 0x2264, 0x2265, 0x2282, 0x2283,
|
||||
0x22a2, 0x22a3, 0x22a4, 0x22a5, 0x2308, 0x230a, 0x2315, 0x2320,
|
||||
0x2321, 0x2395, 0x239b, 0x239d, 0x239e, 0x23a0, 0x23a1, 0x23a3,
|
||||
0x23a4, 0x23a6, 0x23a8, 0x23ac, 0x23b7, 0x23ba, 0x23bb, 0x23bc,
|
||||
0x23bd, 0x2409, 0x240a, 0x240b, 0x240c, 0x240d, 0x2424, 0x2500,
|
||||
0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524, 0x252c,
|
||||
0x2534, 0x253c, 0x2592, 0x25c6, 0x25cb, 0x260e, 0x2640, 0x2642,
|
||||
0x2663, 0x2665, 0x2666, 0x266d, 0x266f, 0x2713, 0x2717, 0x271d,
|
||||
0x2720, 0x3001, 0x3002, 0x300c, 0x300d, 0x309b, 0x309c, 0x30a1,
|
||||
0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8, 0x30a9,
|
||||
0x30aa, 0x30ab, 0x30ad, 0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7,
|
||||
0x30b9, 0x30bb, 0x30bd, 0x30bf, 0x30c1, 0x30c3, 0x30c4, 0x30c6,
|
||||
0x30c8, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d2,
|
||||
0x30d5, 0x30d8, 0x30db, 0x30de, 0x30df, 0x30e0, 0x30e1, 0x30e2,
|
||||
0x30e3, 0x30e4, 0x30e5, 0x30e6, 0x30e7, 0x30e8, 0x30e9, 0x30ea,
|
||||
0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f2, 0x30f3, 0x30fb, 0x30fc
|
||||
};
|
||||
|
||||
const uint AutoTypePlatformX11::m_unicodeToKeysymValues[] = {
|
||||
0x03c0, 0x03e0, 0x01c3, 0x01e3, 0x01a1, 0x01b1, 0x01c6, 0x01e6,
|
||||
0x02c6, 0x02e6, 0x02c5, 0x02e5, 0x01c8, 0x01e8, 0x01cf, 0x01ef,
|
||||
0x01d0, 0x01f0, 0x03aa, 0x03ba, 0x03cc, 0x03ec, 0x01ca, 0x01ea,
|
||||
0x01cc, 0x01ec, 0x02d8, 0x02f8, 0x02ab, 0x02bb, 0x02d5, 0x02f5,
|
||||
0x03ab, 0x03bb, 0x02a6, 0x02b6, 0x02a1, 0x02b1, 0x03a5, 0x03b5,
|
||||
0x03cf, 0x03ef, 0x03c7, 0x03e7, 0x02a9, 0x02b9, 0x02ac, 0x02bc,
|
||||
0x03d3, 0x03f3, 0x03a2, 0x01c5, 0x01e5, 0x03a6, 0x03b6, 0x01a5,
|
||||
0x01b5, 0x01a3, 0x01b3, 0x01d1, 0x01f1, 0x03d1, 0x03f1, 0x01d2,
|
||||
0x01f2, 0x03bd, 0x03bf, 0x03d2, 0x03f2, 0x01d5, 0x01f5, 0x13bc,
|
||||
0x13bd, 0x01c0, 0x01e0, 0x03a3, 0x03b3, 0x01d8, 0x01f8, 0x01a6,
|
||||
0x01b6, 0x02de, 0x02fe, 0x01aa, 0x01ba, 0x01a9, 0x01b9, 0x01de,
|
||||
0x01fe, 0x01ab, 0x01bb, 0x03ac, 0x03bc, 0x03dd, 0x03fd, 0x03de,
|
||||
0x03fe, 0x02dd, 0x02fd, 0x01d9, 0x01f9, 0x01db, 0x01fb, 0x03d9,
|
||||
0x03f9, 0x13be, 0x01ac, 0x01bc, 0x01af, 0x01bf, 0x01ae, 0x01be,
|
||||
0x08f6, 0x01b7, 0x01a2, 0x01ff, 0x01b2, 0x01bd, 0x07ae, 0x07a1,
|
||||
0x07a2, 0x07a3, 0x07a4, 0x07a7, 0x07a8, 0x07ab, 0x07b6, 0x07c1,
|
||||
0x07c2, 0x07c3, 0x07c4, 0x07c5, 0x07c6, 0x07c7, 0x07c8, 0x07c9,
|
||||
0x07ca, 0x07cb, 0x07cc, 0x07cd, 0x07ce, 0x07cf, 0x07d0, 0x07d1,
|
||||
0x07d2, 0x07d4, 0x07d5, 0x07d6, 0x07d7, 0x07d8, 0x07d9, 0x07a5,
|
||||
0x07a9, 0x07b1, 0x07b2, 0x07b3, 0x07b4, 0x07ba, 0x07e1, 0x07e2,
|
||||
0x07e3, 0x07e4, 0x07e5, 0x07e6, 0x07e7, 0x07e8, 0x07e9, 0x07ea,
|
||||
0x07eb, 0x07ec, 0x07ed, 0x07ee, 0x07ef, 0x07f0, 0x07f1, 0x07f3,
|
||||
0x07f2, 0x07f4, 0x07f5, 0x07f6, 0x07f7, 0x07f8, 0x07f9, 0x07b5,
|
||||
0x07b9, 0x07b7, 0x07b8, 0x07bb, 0x06b3, 0x06b1, 0x06b2, 0x06b4,
|
||||
0x06b5, 0x06b6, 0x06b7, 0x06b8, 0x06b9, 0x06ba, 0x06bb, 0x06bc,
|
||||
0x06be, 0x06bf, 0x06e1, 0x06e2, 0x06f7, 0x06e7, 0x06e4, 0x06e5,
|
||||
0x06f6, 0x06fa, 0x06e9, 0x06ea, 0x06eb, 0x06ec, 0x06ed, 0x06ee,
|
||||
0x06ef, 0x06f0, 0x06f2, 0x06f3, 0x06f4, 0x06f5, 0x06e6, 0x06e8,
|
||||
0x06e3, 0x06fe, 0x06fb, 0x06fd, 0x06ff, 0x06f9, 0x06f8, 0x06fc,
|
||||
0x06e0, 0x06f1, 0x06c1, 0x06c2, 0x06d7, 0x06c7, 0x06c4, 0x06c5,
|
||||
0x06d6, 0x06da, 0x06c9, 0x06ca, 0x06cb, 0x06cc, 0x06cd, 0x06ce,
|
||||
0x06cf, 0x06d0, 0x06d2, 0x06d3, 0x06d4, 0x06d5, 0x06c6, 0x06c8,
|
||||
0x06c3, 0x06de, 0x06db, 0x06dd, 0x06df, 0x06d9, 0x06d8, 0x06dc,
|
||||
0x06c0, 0x06d1, 0x06a3, 0x06a1, 0x06a2, 0x06a4, 0x06a5, 0x06a6,
|
||||
0x06a7, 0x06a8, 0x06a9, 0x06aa, 0x06ab, 0x06ac, 0x06ae, 0x06af,
|
||||
0x06bd, 0x06ad, 0x0ce0, 0x0ce1, 0x0ce2, 0x0ce3, 0x0ce4, 0x0ce5,
|
||||
0x0ce6, 0x0ce7, 0x0ce8, 0x0ce9, 0x0cea, 0x0ceb, 0x0cec, 0x0ced,
|
||||
0x0cee, 0x0cef, 0x0cf0, 0x0cf1, 0x0cf2, 0x0cf3, 0x0cf4, 0x0cf5,
|
||||
0x0cf6, 0x0cf7, 0x0cf8, 0x0cf9, 0x0cfa, 0x05ac, 0x05bb, 0x05bf,
|
||||
0x05c1, 0x05c2, 0x05c3, 0x05c4, 0x05c5, 0x05c6, 0x05c7, 0x05c8,
|
||||
0x05c9, 0x05ca, 0x05cb, 0x05cc, 0x05cd, 0x05ce, 0x05cf, 0x05d0,
|
||||
0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, 0x05d8,
|
||||
0x05d9, 0x05da, 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5,
|
||||
0x05e6, 0x05e7, 0x05e8, 0x05e9, 0x05ea, 0x05eb, 0x05ec, 0x05ed,
|
||||
0x05ee, 0x05ef, 0x05f0, 0x05f1, 0x05f2, 0x0da1, 0x0da2, 0x0da3,
|
||||
0x0da4, 0x0da5, 0x0da6, 0x0da7, 0x0da8, 0x0da9, 0x0daa, 0x0dab,
|
||||
0x0dac, 0x0dad, 0x0dae, 0x0daf, 0x0db0, 0x0db1, 0x0db2, 0x0db3,
|
||||
0x0db4, 0x0db5, 0x0db6, 0x0db7, 0x0db8, 0x0db9, 0x0dba, 0x0dbb,
|
||||
0x0dbc, 0x0dbd, 0x0dbe, 0x0dbf, 0x0dc0, 0x0dc1, 0x0dc2, 0x0dc3,
|
||||
0x0dc4, 0x0dc5, 0x0dc6, 0x0dc7, 0x0dc8, 0x0dc9, 0x0dca, 0x0dcb,
|
||||
0x0dcc, 0x0dcd, 0x0dce, 0x0dcf, 0x0dd0, 0x0dd1, 0x0dd2, 0x0dd3,
|
||||
0x0dd4, 0x0dd5, 0x0dd6, 0x0dd7, 0x0dd8, 0x0dd9, 0x0dda, 0x0ddf,
|
||||
0x0de0, 0x0de1, 0x0de2, 0x0de3, 0x0de4, 0x0de5, 0x0de6, 0x0de7,
|
||||
0x0de8, 0x0de9, 0x0dea, 0x0deb, 0x0dec, 0x0ded, 0x0df0, 0x0df1,
|
||||
0x0df2, 0x0df3, 0x0df4, 0x0df5, 0x0df6, 0x0df7, 0x0df8, 0x0df9,
|
||||
0x0aa2, 0x0aa1, 0x0aa3, 0x0aa4, 0x0aa5, 0x0aa6, 0x0aa7, 0x0aa8,
|
||||
0x0abb, 0x0aaa, 0x0aa9, 0x07af, 0x0cdf, 0x0ad0, 0x0ad1, 0x0afd,
|
||||
0x0ad2, 0x0ad3, 0x0afe, 0x0af1, 0x0af2, 0x0aaf, 0x0aae, 0x0ad5,
|
||||
0x0ad6, 0x0ad7, 0x0afc, 0x047e, 0x20ac, 0x0ab8, 0x06b0, 0x0afb,
|
||||
0x0ad4, 0x0ac9, 0x0ab0, 0x0ab1, 0x0ab2, 0x0ab3, 0x0ab4, 0x0ab5,
|
||||
0x0ab6, 0x0ab7, 0x0ac3, 0x0ac4, 0x0ac5, 0x0ac6, 0x08fb, 0x08fc,
|
||||
0x08fd, 0x08fe, 0x08ce, 0x08cd, 0x08ef, 0x08c5, 0x0bca, 0x08d6,
|
||||
0x08c1, 0x08c2, 0x08de, 0x08df, 0x08dc, 0x08dd, 0x08bf, 0x08c0,
|
||||
0x08c8, 0x08c9, 0x08bd, 0x08cf, 0x08bc, 0x08be, 0x08da, 0x08db,
|
||||
0x0bfc, 0x0bdc, 0x0bc2, 0x0bce, 0x0bd3, 0x0bc4, 0x0afa, 0x08a4,
|
||||
0x08a5, 0x0bcc, 0x08ab, 0x08ac, 0x08ad, 0x08ae, 0x08a7, 0x08a8,
|
||||
0x08a9, 0x08aa, 0x08af, 0x08b0, 0x08a1, 0x09ef, 0x09f0, 0x09f2,
|
||||
0x09f3, 0x09e2, 0x09e5, 0x09e9, 0x09e3, 0x09e4, 0x09e8, 0x09f1,
|
||||
0x09f8, 0x09ec, 0x09eb, 0x09ed, 0x09ea, 0x09f4, 0x09f5, 0x09f7,
|
||||
0x09f6, 0x09ee, 0x09e1, 0x09e0, 0x0bcf, 0x0af9, 0x0af8, 0x0af7,
|
||||
0x0aec, 0x0aee, 0x0aed, 0x0af6, 0x0af5, 0x0af3, 0x0af4, 0x0ad9,
|
||||
0x0af0, 0x04a4, 0x04a1, 0x04a2, 0x04a3, 0x04de, 0x04df, 0x04a7,
|
||||
0x04b1, 0x04a8, 0x04b2, 0x04a9, 0x04b3, 0x04aa, 0x04b4, 0x04ab,
|
||||
0x04b5, 0x04b6, 0x04b7, 0x04b8, 0x04b9, 0x04ba, 0x04bb, 0x04bc,
|
||||
0x04bd, 0x04be, 0x04bf, 0x04c0, 0x04c1, 0x04af, 0x04c2, 0x04c3,
|
||||
0x04c4, 0x04c5, 0x04c6, 0x04c7, 0x04c8, 0x04c9, 0x04ca, 0x04cb,
|
||||
0x04cc, 0x04cd, 0x04ce, 0x04cf, 0x04d0, 0x04d1, 0x04d2, 0x04d3,
|
||||
0x04ac, 0x04d4, 0x04ad, 0x04d5, 0x04ae, 0x04d6, 0x04d7, 0x04d8,
|
||||
0x04d9, 0x04da, 0x04db, 0x04dc, 0x04a6, 0x04dd, 0x04a5, 0x04b0
|
||||
};
|
||||
107
src/autotype/x11/keysymmap.py
Executable file
107
src/autotype/x11/keysymmap.py
Executable file
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
#
|
||||
# Copyright (C) 2013 Felix Geyer <debfx@fobos.de>
|
||||
#
|
||||
# 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 or (at your option)
|
||||
# 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.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#
|
||||
# Parses keysymdef.h to construct a unicode symbol -> keysym mapping table.
|
||||
#
|
||||
# The lines that are parsed look like this:
|
||||
# #define XK_Aogonek 0x01a1 /* U+0104 LATIN CAPITAL LETTER A WITH OGONEK */
|
||||
#
|
||||
# This would create a 0x0104 -> 0x01a1 mapping.
|
||||
#
|
||||
|
||||
import sys
|
||||
import re
|
||||
import collections
|
||||
|
||||
cols = 8
|
||||
|
||||
if len(sys.argv) >= 2:
|
||||
keysymdef = sys.argv[1]
|
||||
else:
|
||||
keysymdef = "/usr/include/X11/keysymdef.h"
|
||||
|
||||
keysymMap = {}
|
||||
|
||||
f = open(keysymdef, "r")
|
||||
for line in f:
|
||||
match = re.search(r'0x([0-9a-fA-F]+)\s+/\* U\+([0-9a-fA-F]+)', line)
|
||||
if match:
|
||||
keysym = int(match.group(1), 16)
|
||||
unicodeVal = int(match.group(2), 16)
|
||||
|
||||
# ignore 1:1 mappings
|
||||
if keysym >= 0x0020 and keysym <= 0x007e:
|
||||
continue
|
||||
if keysym >= 0x00a0 and keysym <= 0x00ff:
|
||||
continue
|
||||
# ignore unicode | 0x01000000 mappings
|
||||
if keysym >= 0x1000000:
|
||||
continue
|
||||
|
||||
keysymMap[unicodeVal] = keysym
|
||||
|
||||
keysymMap = collections.OrderedDict(sorted(keysymMap.items(), key=lambda t: t[0]))
|
||||
|
||||
print("""/*
|
||||
* Automatically generated by keysymmap.py from parsing keysymdef.h.
|
||||
*/
|
||||
""")
|
||||
|
||||
print("const int AutoTypePlatformX11::m_unicodeToKeysymLen = " + str(len(keysymMap)) + ";")
|
||||
|
||||
print()
|
||||
|
||||
print("const uint AutoTypePlatformX11::m_unicodeToKeysymKeys[] = {")
|
||||
keys = keysymMap.keys()
|
||||
keyLen = len(keys)
|
||||
i = 1
|
||||
for val in keys:
|
||||
hexVal = "{0:#0{1}x}".format(val, 6)
|
||||
|
||||
if i == keyLen:
|
||||
print(hexVal)
|
||||
elif (i % cols) == 0:
|
||||
print(hexVal + ",")
|
||||
elif ((i - 1) % cols) == 0:
|
||||
print(" " + hexVal + ", ", end="")
|
||||
else:
|
||||
print(hexVal + ", ", end="")
|
||||
i += 1
|
||||
print("};")
|
||||
|
||||
print()
|
||||
|
||||
print("const uint AutoTypePlatformX11::m_unicodeToKeysymValues[] = {")
|
||||
values = keysymMap.values()
|
||||
valuesLen = len(values)
|
||||
i = 1
|
||||
for val in values:
|
||||
hexVal = "{0:#0{1}x}".format(val, 6)
|
||||
|
||||
if i == valuesLen:
|
||||
print(hexVal)
|
||||
elif (i % cols) == 0:
|
||||
print(hexVal + ",")
|
||||
elif ((i - 1) % cols) == 0:
|
||||
print(" " + hexVal + ", ", end="")
|
||||
else:
|
||||
print(hexVal + ", ", end="")
|
||||
i += 1
|
||||
print("};")
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#define KEEPASSX_SOURCE_DIR "${CMAKE_SOURCE_DIR}"
|
||||
|
||||
#define KEEPASSX_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}"
|
||||
|
||||
#cmakedefine HAVE_PR_SET_DUMPABLE 1
|
||||
#cmakedefine HAVE_RLIMIT_CORE 1
|
||||
#cmakedefine HAVE_PT_DENY_ATTACH 1
|
||||
|
||||
56
src/core/ArgumentParser.cpp
Normal file
56
src/core/ArgumentParser.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Florian Geyer <blueice@fobos.de>
|
||||
*
|
||||
* 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 or (at your option)
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ArgumentParser.h"
|
||||
|
||||
const QStringList ArgumentParser::ArgumentKeys = QStringList() << "password" << "config" << "filename";
|
||||
|
||||
QHash<QString, QString> ArgumentParser::parseArguments(const QStringList& args)
|
||||
{
|
||||
QHash<QString, QString> argumentMap;
|
||||
|
||||
for (int i = 1; i < args.size(); i++) {
|
||||
if (args[i].startsWith("--")) {
|
||||
parseOption(i, argumentMap, args);
|
||||
}
|
||||
else if (!args[i].startsWith("-")) {
|
||||
argumentMap.insert("filename", args[i]);
|
||||
}
|
||||
else {
|
||||
qWarning("Unknown argument \"%s\"", qPrintable(args[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return argumentMap;
|
||||
}
|
||||
|
||||
void ArgumentParser::parseOption(int& i, QHash<QString, QString>& argumentMap, const QStringList& args)
|
||||
{
|
||||
if (args.size() < (i + 2)) {
|
||||
qWarning("No value given for option \"%s\"", qPrintable(args[i]));
|
||||
return;
|
||||
}
|
||||
|
||||
QString argument(args[i].mid(2));
|
||||
if (ArgumentKeys.contains(argument)) {
|
||||
argumentMap.insert(argument, args[i + 1]);
|
||||
}
|
||||
else {
|
||||
qWarning("Unknown option \"%s\" with value \"%s\"", qPrintable(args[i]), qPrintable(args[i+1]));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
37
src/core/ArgumentParser.h
Normal file
37
src/core/ArgumentParser.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Florian Geyer <blueice@fobos.de>
|
||||
*
|
||||
* 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 or (at your option)
|
||||
* 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.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_ARGUMENTPARSER_H
|
||||
#define KEEPASSX_ARGUMENTPARSER_H
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QStringList>
|
||||
|
||||
class ArgumentParser
|
||||
{
|
||||
public:
|
||||
static QHash<QString, QString> parseArguments(const QStringList& args);
|
||||
|
||||
private:
|
||||
static void parseOption(int& i, QHash<QString, QString>& argumentMap, const QStringList& args);
|
||||
|
||||
static const QStringList ArgumentKeys;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ARGUMENTPARSER_H
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_AUTOTYPEASSOCIATIONS_H
|
||||
#define KEEPASSX_AUTOTYPEASSOCIATIONS_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QObject>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QDesktopServices>
|
||||
#include <QCoreApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
Config* Config::m_instance(Q_NULLPTR);
|
||||
|
||||
@@ -88,10 +88,12 @@ void Config::init(const QString& fileName)
|
||||
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
|
||||
|
||||
m_defaults.insert("RememberLastDatabases", true);
|
||||
m_defaults.insert("OpenPreviousDatabasesOnStartup", true);
|
||||
m_defaults.insert("ModifiedOnExpandedStateChanges", true);
|
||||
m_defaults.insert("AutoSaveAfterEveryChange", false);
|
||||
m_defaults.insert("AutoSaveOnExit", false);
|
||||
m_defaults.insert("ShowToolbar", true);
|
||||
m_defaults.insert("MinimizeOnCopy", false);
|
||||
m_defaults.insert("security/clearclipboard", true);
|
||||
m_defaults.insert("security/clearclipboardtimeout", 10);
|
||||
}
|
||||
@@ -105,6 +107,12 @@ Config* Config::instance()
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void Config::createConfigFromFile(QString file)
|
||||
{
|
||||
Q_ASSERT(!m_instance);
|
||||
m_instance = new Config(file, qApp);
|
||||
}
|
||||
|
||||
void Config::createTempFileInstance()
|
||||
{
|
||||
Q_ASSERT(!m_instance);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_CONFIG_H
|
||||
#define KEEPASSX_CONFIG_H
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QScopedPointer>
|
||||
#include <QVariant>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
void set(const QString& key, const QVariant& value);
|
||||
|
||||
static Config* instance();
|
||||
static void createConfigFromFile(QString file);
|
||||
static void createTempFileInstance();
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include "Database.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
@@ -32,13 +32,14 @@ QHash<Uuid, Database*> Database::m_uuidMap;
|
||||
Database::Database()
|
||||
: m_metadata(new Metadata(this))
|
||||
, m_timer(new QTimer(this))
|
||||
, m_cipher(KeePass2::CIPHER_AES)
|
||||
, m_compressionAlgo(CompressionGZip)
|
||||
, m_transformRounds(50000)
|
||||
, m_hasKey(false)
|
||||
, m_emitModified(false)
|
||||
, m_uuid(Uuid::random())
|
||||
{
|
||||
m_data.cipher = KeePass2::CIPHER_AES;
|
||||
m_data.compressionAlgo = CompressionGZip;
|
||||
m_data.transformRounds = 50000;
|
||||
m_data.hasKey = false;
|
||||
|
||||
setRootGroup(new Group());
|
||||
rootGroup()->setUuid(Uuid::random());
|
||||
m_timer->setSingleShot(true);
|
||||
@@ -150,60 +151,60 @@ void Database::addDeletedObject(const Uuid& uuid)
|
||||
|
||||
Uuid Database::cipher() const
|
||||
{
|
||||
return m_cipher;
|
||||
return m_data.cipher;
|
||||
}
|
||||
|
||||
Database::CompressionAlgorithm Database::compressionAlgo() const
|
||||
{
|
||||
return m_compressionAlgo;
|
||||
return m_data.compressionAlgo;
|
||||
}
|
||||
|
||||
QByteArray Database::transformSeed() const
|
||||
{
|
||||
return m_transformSeed;
|
||||
return m_data.transformSeed;
|
||||
}
|
||||
|
||||
quint64 Database::transformRounds() const
|
||||
{
|
||||
return m_transformRounds;
|
||||
return m_data.transformRounds;
|
||||
}
|
||||
|
||||
QByteArray Database::transformedMasterKey() const
|
||||
{
|
||||
return m_transformedMasterKey;
|
||||
return m_data.transformedMasterKey;
|
||||
}
|
||||
|
||||
void Database::setCipher(const Uuid& cipher)
|
||||
{
|
||||
Q_ASSERT(!cipher.isNull());
|
||||
|
||||
m_cipher = cipher;
|
||||
m_data.cipher = cipher;
|
||||
}
|
||||
|
||||
void Database::setCompressionAlgo(Database::CompressionAlgorithm algo)
|
||||
{
|
||||
Q_ASSERT(static_cast<quint32>(algo) <= CompressionAlgorithmMax);
|
||||
|
||||
m_compressionAlgo = algo;
|
||||
m_data.compressionAlgo = algo;
|
||||
}
|
||||
|
||||
void Database::setTransformRounds(quint64 rounds)
|
||||
{
|
||||
if (m_transformRounds != rounds) {
|
||||
m_transformRounds = rounds;
|
||||
if (m_data.transformRounds != rounds) {
|
||||
m_data.transformRounds = rounds;
|
||||
|
||||
if (m_hasKey) {
|
||||
setKey(m_key);
|
||||
if (m_data.hasKey) {
|
||||
setKey(m_data.key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed, bool updateChangedTime)
|
||||
{
|
||||
m_key = key;
|
||||
m_transformSeed = transformSeed;
|
||||
m_transformedMasterKey = key.transform(transformSeed, transformRounds());
|
||||
m_hasKey = true;
|
||||
m_data.key = key;
|
||||
m_data.transformSeed = transformSeed;
|
||||
m_data.transformedMasterKey = key.transform(transformSeed, transformRounds());
|
||||
m_data.hasKey = true;
|
||||
if (updateChangedTime) {
|
||||
m_metadata->setMasterKeyChanged(Tools::currentDateTimeUtc());
|
||||
}
|
||||
@@ -212,19 +213,19 @@ void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed,
|
||||
|
||||
void Database::setKey(const CompositeKey& key)
|
||||
{
|
||||
setKey(key, Random::randomArray(32));
|
||||
setKey(key, randomGen()->randomArray(32));
|
||||
}
|
||||
|
||||
bool Database::hasKey() const
|
||||
{
|
||||
return m_hasKey;
|
||||
return m_data.hasKey;
|
||||
}
|
||||
|
||||
bool Database::verifyKey(const CompositeKey& key) const
|
||||
{
|
||||
Q_ASSERT(hasKey());
|
||||
|
||||
return (m_key.rawKey() == key.rawKey());
|
||||
return (m_data.key.rawKey() == key.rawKey());
|
||||
}
|
||||
|
||||
void Database::createRecycleBin()
|
||||
@@ -269,6 +270,12 @@ void Database::setEmitModified(bool value)
|
||||
m_emitModified = value;
|
||||
}
|
||||
|
||||
void Database::copyAttributesFrom(const Database* other)
|
||||
{
|
||||
m_data = other->m_data;
|
||||
m_metadata->copyAttributesFrom(other->m_metadata);
|
||||
}
|
||||
|
||||
Uuid Database::uuid()
|
||||
{
|
||||
return m_uuid;
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_DATABASE_H
|
||||
#define KEEPASSX_DATABASE_H
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
#include "keys/CompositeKey.h"
|
||||
@@ -49,6 +49,17 @@ public:
|
||||
};
|
||||
static const quint32 CompressionAlgorithmMax = CompressionGZip;
|
||||
|
||||
struct DatabaseData
|
||||
{
|
||||
Uuid cipher;
|
||||
CompressionAlgorithm compressionAlgo;
|
||||
QByteArray transformSeed;
|
||||
quint64 transformRounds;
|
||||
QByteArray transformedMasterKey;
|
||||
CompositeKey key;
|
||||
bool hasKey;
|
||||
};
|
||||
|
||||
Database();
|
||||
~Database();
|
||||
Group* rootGroup();
|
||||
@@ -91,6 +102,7 @@ public:
|
||||
void recycleEntry(Entry* entry);
|
||||
void recycleGroup(Group* group);
|
||||
void setEmitModified(bool value);
|
||||
void copyAttributesFrom(const Database* other);
|
||||
|
||||
/**
|
||||
* Returns a unique id that is only valid as long as the Database exists.
|
||||
@@ -124,15 +136,7 @@ private:
|
||||
Group* m_rootGroup;
|
||||
QList<DeletedObject> m_deletedObjects;
|
||||
QTimer* m_timer;
|
||||
|
||||
Uuid m_cipher;
|
||||
CompressionAlgorithm m_compressionAlgo;
|
||||
QByteArray m_transformSeed;
|
||||
quint64 m_transformRounds;
|
||||
QByteArray m_transformedMasterKey;
|
||||
|
||||
CompositeKey m_key;
|
||||
bool m_hasKey;
|
||||
DatabaseData m_data;
|
||||
bool m_emitModified;
|
||||
|
||||
Uuid m_uuid;
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#ifndef KEEPASSX_DATABASEICONS_H
|
||||
#define KEEPASSX_DATABASEICONS_H
|
||||
|
||||
#include <QtCore/QVector>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QPixmapCache>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QVector>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "Endian.h"
|
||||
|
||||
#include <QtCore/QtEndian>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtEndian>
|
||||
#include <QIODevice>
|
||||
|
||||
namespace Endian {
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_ENDIAN_H
|
||||
#define KEEPASSX_ENDIAN_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QSysInfo>
|
||||
#include <QByteArray>
|
||||
#include <QSysInfo>
|
||||
|
||||
class QIODevice;
|
||||
|
||||
|
||||
@@ -94,8 +94,14 @@ QImage Entry::icon() const
|
||||
return databaseIcons()->icon(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
// TODO: check if database() is 0
|
||||
return database()->metadata()->customIcon(m_data.customIcon);
|
||||
Q_ASSERT(database());
|
||||
|
||||
if (database()) {
|
||||
return database()->metadata()->customIcon(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,9 +111,10 @@ QPixmap Entry::iconPixmap() const
|
||||
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
Q_ASSERT(database());
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
// TODO: check if database() is 0
|
||||
if (database() && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
|
||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
@@ -178,27 +185,27 @@ const AutoTypeAssociations* Entry::autoTypeAssociations() const
|
||||
|
||||
QString Entry::title() const
|
||||
{
|
||||
return m_attributes->value("Title");
|
||||
return m_attributes->value(EntryAttributes::TitleKey);
|
||||
}
|
||||
|
||||
QString Entry::url() const
|
||||
{
|
||||
return m_attributes->value("URL");
|
||||
return m_attributes->value(EntryAttributes::URLKey);
|
||||
}
|
||||
|
||||
QString Entry::username() const
|
||||
{
|
||||
return m_attributes->value("UserName");
|
||||
return m_attributes->value(EntryAttributes::UserNameKey);
|
||||
}
|
||||
|
||||
QString Entry::password() const
|
||||
{
|
||||
return m_attributes->value("Password");
|
||||
return m_attributes->value(EntryAttributes::PasswordKey);
|
||||
}
|
||||
|
||||
QString Entry::notes() const
|
||||
{
|
||||
return m_attributes->value("Notes");
|
||||
return m_attributes->value(EntryAttributes::NotesKey);
|
||||
}
|
||||
|
||||
bool Entry::isExpired() const
|
||||
@@ -304,27 +311,27 @@ void Entry::setDefaultAutoTypeSequence(const QString& sequence)
|
||||
|
||||
void Entry::setTitle(const QString& title)
|
||||
{
|
||||
m_attributes->set("Title", title, m_attributes->isProtected("Title"));
|
||||
m_attributes->set(EntryAttributes::TitleKey, title, m_attributes->isProtected(EntryAttributes::TitleKey));
|
||||
}
|
||||
|
||||
void Entry::setUrl(const QString& url)
|
||||
{
|
||||
m_attributes->set("URL", url, m_attributes->isProtected("URL"));
|
||||
m_attributes->set(EntryAttributes::URLKey, url, m_attributes->isProtected(EntryAttributes::URLKey));
|
||||
}
|
||||
|
||||
void Entry::setUsername(const QString& username)
|
||||
{
|
||||
m_attributes->set("UserName", username, m_attributes->isProtected("UserName"));
|
||||
m_attributes->set(EntryAttributes::UserNameKey, username, m_attributes->isProtected(EntryAttributes::UserNameKey));
|
||||
}
|
||||
|
||||
void Entry::setPassword(const QString& password)
|
||||
{
|
||||
m_attributes->set("Password", password, m_attributes->isProtected("Password"));
|
||||
m_attributes->set(EntryAttributes::PasswordKey, password, m_attributes->isProtected(EntryAttributes::PasswordKey));
|
||||
}
|
||||
|
||||
void Entry::setNotes(const QString& notes)
|
||||
{
|
||||
m_attributes->set("Notes", notes, m_attributes->isProtected("Notes"));
|
||||
m_attributes->set(EntryAttributes::NotesKey, notes, m_attributes->isProtected(EntryAttributes::NotesKey));
|
||||
}
|
||||
|
||||
void Entry::setExpires(const bool& value)
|
||||
@@ -432,26 +439,54 @@ void Entry::truncateHistory()
|
||||
}
|
||||
}
|
||||
|
||||
Entry* Entry::clone() const
|
||||
Entry* Entry::clone(CloneFlags flags) const
|
||||
{
|
||||
Entry* entry = new Entry();
|
||||
entry->setUpdateTimeinfo(false);
|
||||
entry->m_uuid = m_uuid;
|
||||
if (flags & CloneNewUuid) {
|
||||
entry->m_uuid = Uuid::random();
|
||||
}
|
||||
else {
|
||||
entry->m_uuid = m_uuid;
|
||||
}
|
||||
entry->m_data = m_data;
|
||||
entry->m_attributes->copyDataFrom(m_attributes);
|
||||
entry->m_attachments->copyDataFrom(m_attachments);
|
||||
entry->m_autoTypeAssociations->copyDataFrom(this->m_autoTypeAssociations);
|
||||
if (flags & CloneIncludeHistory) {
|
||||
Q_FOREACH (Entry* historyItem, m_history) {
|
||||
Entry* historyItemClone = historyItem->clone(flags & ~CloneIncludeHistory & ~CloneNewUuid);
|
||||
historyItemClone->setUpdateTimeinfo(false);
|
||||
historyItemClone->setUuid(entry->uuid());
|
||||
historyItemClone->setUpdateTimeinfo(true);
|
||||
entry->addHistoryItem(historyItemClone);
|
||||
}
|
||||
}
|
||||
entry->setUpdateTimeinfo(true);
|
||||
|
||||
QDateTime now = Tools::currentDateTimeUtc();
|
||||
entry->m_data.timeInfo.setCreationTime(now);
|
||||
entry->m_data.timeInfo.setLastModificationTime(now);
|
||||
entry->m_data.timeInfo.setLastAccessTime(now);
|
||||
entry->m_data.timeInfo.setLocationChanged(now);
|
||||
if (flags & CloneResetTimeInfo) {
|
||||
QDateTime now = Tools::currentDateTimeUtc();
|
||||
entry->m_data.timeInfo.setCreationTime(now);
|
||||
entry->m_data.timeInfo.setLastModificationTime(now);
|
||||
entry->m_data.timeInfo.setLastAccessTime(now);
|
||||
entry->m_data.timeInfo.setLocationChanged(now);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
void Entry::copyDataFrom(const Entry* other)
|
||||
{
|
||||
setUpdateTimeinfo(false);
|
||||
m_data = other->m_data;
|
||||
m_attributes->copyDataFrom(other->m_attributes);
|
||||
m_attachments->copyDataFrom(other->m_attachments);
|
||||
m_autoTypeAssociations->copyDataFrom(other->m_autoTypeAssociations);
|
||||
setUpdateTimeinfo(true);
|
||||
}
|
||||
|
||||
void Entry::beginUpdate()
|
||||
{
|
||||
Q_ASSERT(!m_tmpHistoryItem);
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
#ifndef KEEPASSX_ENTRY_H
|
||||
#define KEEPASSX_ENTRY_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QUrl>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QPixmapCache>
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
#include <QMap>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
#include <QUrl>
|
||||
|
||||
#include "core/AutoTypeAssociations.h"
|
||||
#include "core/EntryAttachments.h"
|
||||
@@ -110,7 +110,23 @@ public:
|
||||
void addHistoryItem(Entry* entry);
|
||||
void removeHistoryItems(const QList<Entry*>& historyEntries);
|
||||
void truncateHistory();
|
||||
Entry* clone() const;
|
||||
|
||||
enum CloneFlag {
|
||||
CloneNoFlags = 0,
|
||||
CloneNewUuid = 1, // generate a random uuid for the clone
|
||||
CloneResetTimeInfo = 2, // set all TimeInfo attributes to the current time
|
||||
CloneIncludeHistory = 4 // clone the history items
|
||||
};
|
||||
Q_DECLARE_FLAGS(CloneFlags, CloneFlag)
|
||||
|
||||
/**
|
||||
* Creates a duplicate of this entry except that the returned entry isn't
|
||||
* part of any group.
|
||||
* Note that you need to copy the custom icons manually when inserting the
|
||||
* new entry into another database.
|
||||
*/
|
||||
Entry* clone(CloneFlags flags) const;
|
||||
void copyDataFrom(const Entry* other);
|
||||
QString resolvePlaceholders(const QString& str) const;
|
||||
|
||||
/**
|
||||
@@ -159,4 +175,6 @@ private:
|
||||
bool m_updateTimeinfo;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Entry::CloneFlags)
|
||||
|
||||
#endif // KEEPASSX_ENTRY_H
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_ENTRYATTACHMENTS_H
|
||||
#define KEEPASSX_ENTRYATTACHMENTS_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QObject>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,8 +17,13 @@
|
||||
|
||||
#include "EntryAttributes.h"
|
||||
|
||||
const QStringList EntryAttributes::DefaultAttributes(QStringList() << "Title" << "UserName"
|
||||
<< "Password" << "URL" << "Notes");
|
||||
const QString EntryAttributes::TitleKey = "Title";
|
||||
const QString EntryAttributes::UserNameKey = "UserName";
|
||||
const QString EntryAttributes::PasswordKey = "Password";
|
||||
const QString EntryAttributes::URLKey = "URL";
|
||||
const QString EntryAttributes::NotesKey = "Notes";
|
||||
const QStringList EntryAttributes::DefaultAttributes(QStringList() << TitleKey << UserNameKey
|
||||
<< PasswordKey << URLKey << NotesKey);
|
||||
|
||||
EntryAttributes::EntryAttributes(QObject* parent)
|
||||
: QObject(parent)
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#ifndef KEEPASSX_ENTRYATTRIBUTES_H
|
||||
#define KEEPASSX_ENTRYATTRIBUTES_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QSet>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
@@ -46,6 +46,11 @@ public:
|
||||
bool operator==(const EntryAttributes& other) const;
|
||||
bool operator!=(const EntryAttributes& other) const;
|
||||
|
||||
static const QString TitleKey;
|
||||
static const QString UserNameKey;
|
||||
static const QString PasswordKey;
|
||||
static const QString URLKey;
|
||||
static const QString NotesKey;
|
||||
static const QStringList DefaultAttributes;
|
||||
static bool isDefaultAttribute(const QString& key);
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include "FilePath.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QLibrary>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QLibrary>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
|
||||
@@ -48,7 +48,15 @@ QString FilePath::pluginPath(const QString& name)
|
||||
pluginPaths << QCoreApplication::applicationDirPath() + "/../src/autotype/test";
|
||||
|
||||
pluginPaths << QCoreApplication::applicationDirPath();
|
||||
pluginPaths << QCoreApplication::applicationDirPath() + "/../lib/keepassx";
|
||||
|
||||
QString systemPluginDir = KEEPASSX_PLUGIN_DIR;
|
||||
if (systemPluginDir != ".") {
|
||||
if (!QDir(systemPluginDir).isAbsolute()) {
|
||||
systemPluginDir = QCoreApplication::applicationDirPath() + "/../" + systemPluginDir;
|
||||
systemPluginDir = QDir(systemPluginDir).canonicalPath();
|
||||
}
|
||||
pluginPaths << systemPluginDir;
|
||||
}
|
||||
|
||||
QStringList dirFilter;
|
||||
dirFilter << QString("*%1*").arg(name);
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef KEEPASSX_FILEPATH_H
|
||||
#define KEEPASSX_FILEPATH_H
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QHash>
|
||||
#include <QIcon>
|
||||
#include <QString>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
// mostly copied from qcompilerdetection.h which is part of Qt 5
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef Q_CC_CLANG
|
||||
# if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
|
||||
@@ -125,7 +125,11 @@ template <> class QStaticAssertFailure<true> {};
|
||||
# define KEEPASSX_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define KEEPASSX_EXPORT
|
||||
# define KEEPASSX_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
#ifndef QUINT32_MAX
|
||||
#define QUINT32_MAX 4294967295U
|
||||
#endif
|
||||
|
||||
#endif // KEEPASSX_GLOBAL_H
|
||||
|
||||
@@ -26,12 +26,12 @@ const int Group::DefaultIconNumber = 48;
|
||||
const int Group::RecycleBinIconNumber = 43;
|
||||
|
||||
Group::Group()
|
||||
: m_iconNumber(DefaultIconNumber)
|
||||
, m_isExpanded(true)
|
||||
, m_autoTypeEnabled(Inherit)
|
||||
, m_searchingEnabled(Inherit)
|
||||
, m_updateTimeinfo(true)
|
||||
: m_updateTimeinfo(true)
|
||||
{
|
||||
m_data.iconNumber = DefaultIconNumber;
|
||||
m_data.isExpanded = true;
|
||||
m_data.autoTypeEnabled = Inherit;
|
||||
m_data.searchingEnabled = Inherit;
|
||||
}
|
||||
|
||||
Group::~Group()
|
||||
@@ -84,8 +84,8 @@ template <class P, class V> inline bool Group::set(P& property, const V& value)
|
||||
void Group::updateTimeinfo()
|
||||
{
|
||||
if (m_updateTimeinfo) {
|
||||
m_timeInfo.setLastModificationTime(Tools::currentDateTimeUtc());
|
||||
m_timeInfo.setLastAccessTime(Tools::currentDateTimeUtc());
|
||||
m_data.timeInfo.setLastModificationTime(Tools::currentDateTimeUtc());
|
||||
m_data.timeInfo.setLastAccessTime(Tools::currentDateTimeUtc());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,35 +101,42 @@ Uuid Group::uuid() const
|
||||
|
||||
QString Group::name() const
|
||||
{
|
||||
return m_name;
|
||||
return m_data.name;
|
||||
}
|
||||
|
||||
QString Group::notes() const
|
||||
{
|
||||
return m_notes;
|
||||
return m_data.notes;
|
||||
}
|
||||
|
||||
QImage Group::icon() const
|
||||
{
|
||||
if (m_customIcon.isNull()) {
|
||||
return databaseIcons()->icon(m_iconNumber);
|
||||
if (m_data.customIcon.isNull()) {
|
||||
return databaseIcons()->icon(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
// TODO: check if m_db is 0
|
||||
return m_db->metadata()->customIcon(m_customIcon);
|
||||
Q_ASSERT(m_db);
|
||||
|
||||
if (m_db) {
|
||||
return m_db->metadata()->customIcon(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QPixmap Group::iconPixmap() const
|
||||
{
|
||||
if (m_customIcon.isNull()) {
|
||||
return databaseIcons()->iconPixmap(m_iconNumber);
|
||||
if (m_data.customIcon.isNull()) {
|
||||
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
Q_ASSERT(m_db);
|
||||
|
||||
QPixmap pixmap;
|
||||
if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
// TODO: check if m_db is 0
|
||||
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_customIcon));
|
||||
if (m_db && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_data.customIcon));
|
||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
||||
@@ -139,37 +146,37 @@ QPixmap Group::iconPixmap() const
|
||||
|
||||
int Group::iconNumber() const
|
||||
{
|
||||
return m_iconNumber;
|
||||
return m_data.iconNumber;
|
||||
}
|
||||
|
||||
Uuid Group::iconUuid() const
|
||||
{
|
||||
return m_customIcon;
|
||||
return m_data.customIcon;
|
||||
}
|
||||
|
||||
TimeInfo Group::timeInfo() const
|
||||
{
|
||||
return m_timeInfo;
|
||||
return m_data.timeInfo;
|
||||
}
|
||||
|
||||
bool Group::isExpanded() const
|
||||
{
|
||||
return m_isExpanded;
|
||||
return m_data.isExpanded;
|
||||
}
|
||||
|
||||
QString Group::defaultAutoTypeSequence() const
|
||||
{
|
||||
return m_defaultAutoTypeSequence;
|
||||
return m_data.defaultAutoTypeSequence;
|
||||
}
|
||||
|
||||
Group::TriState Group::autoTypeEnabled() const
|
||||
{
|
||||
return m_autoTypeEnabled;
|
||||
return m_data.autoTypeEnabled;
|
||||
}
|
||||
|
||||
Group::TriState Group::searchingEnabled() const
|
||||
{
|
||||
return m_searchingEnabled;
|
||||
return m_data.searchingEnabled;
|
||||
}
|
||||
|
||||
Entry* Group::lastTopVisibleEntry() const
|
||||
@@ -179,7 +186,7 @@ Entry* Group::lastTopVisibleEntry() const
|
||||
|
||||
bool Group::isExpired() const
|
||||
{
|
||||
return m_timeInfo.expires() && m_timeInfo.expiryTime() < Tools::currentDateTimeUtc();
|
||||
return m_data.timeInfo.expires() && m_data.timeInfo.expiryTime() < Tools::currentDateTimeUtc();
|
||||
}
|
||||
|
||||
void Group::setUuid(const Uuid& uuid)
|
||||
@@ -189,23 +196,23 @@ void Group::setUuid(const Uuid& uuid)
|
||||
|
||||
void Group::setName(const QString& name)
|
||||
{
|
||||
if (set(m_name, name)) {
|
||||
if (set(m_data.name, name)) {
|
||||
Q_EMIT dataChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Group::setNotes(const QString& notes)
|
||||
{
|
||||
set(m_notes, notes);
|
||||
set(m_data.notes, notes);
|
||||
}
|
||||
|
||||
void Group::setIcon(int iconNumber)
|
||||
{
|
||||
Q_ASSERT(iconNumber >= 0);
|
||||
|
||||
if (m_iconNumber != iconNumber || !m_customIcon.isNull()) {
|
||||
m_iconNumber = iconNumber;
|
||||
m_customIcon = Uuid();
|
||||
if (m_data.iconNumber != iconNumber || !m_data.customIcon.isNull()) {
|
||||
m_data.iconNumber = iconNumber;
|
||||
m_data.customIcon = Uuid();
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
|
||||
@@ -219,9 +226,9 @@ void Group::setIcon(const Uuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
|
||||
if (m_customIcon != uuid) {
|
||||
m_customIcon = uuid;
|
||||
m_iconNumber = 0;
|
||||
if (m_data.customIcon != uuid) {
|
||||
m_data.customIcon = uuid;
|
||||
m_data.iconNumber = 0;
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
|
||||
@@ -233,13 +240,13 @@ void Group::setIcon(const Uuid& uuid)
|
||||
|
||||
void Group::setTimeInfo(const TimeInfo& timeInfo)
|
||||
{
|
||||
m_timeInfo = timeInfo;
|
||||
m_data.timeInfo = timeInfo;
|
||||
}
|
||||
|
||||
void Group::setExpanded(bool expanded)
|
||||
{
|
||||
if (m_isExpanded != expanded) {
|
||||
m_isExpanded = expanded;
|
||||
if (m_data.isExpanded != expanded) {
|
||||
m_data.isExpanded = expanded;
|
||||
updateTimeinfo();
|
||||
if (config()->get("ModifiedOnExpandedStateChanges").toBool()) {
|
||||
Q_EMIT modified();
|
||||
@@ -249,17 +256,17 @@ void Group::setExpanded(bool expanded)
|
||||
|
||||
void Group::setDefaultAutoTypeSequence(const QString& sequence)
|
||||
{
|
||||
set(m_defaultAutoTypeSequence, sequence);
|
||||
set(m_data.defaultAutoTypeSequence, sequence);
|
||||
}
|
||||
|
||||
void Group::setAutoTypeEnabled(TriState enable)
|
||||
{
|
||||
set(m_autoTypeEnabled, enable);
|
||||
set(m_data.autoTypeEnabled, enable);
|
||||
}
|
||||
|
||||
void Group::setSearchingEnabled(TriState enable)
|
||||
{
|
||||
set(m_searchingEnabled, enable);
|
||||
set(m_data.searchingEnabled, enable);
|
||||
}
|
||||
|
||||
void Group::setLastTopVisibleEntry(Entry* entry)
|
||||
@@ -269,8 +276,8 @@ void Group::setLastTopVisibleEntry(Entry* entry)
|
||||
|
||||
void Group::setExpires(bool value)
|
||||
{
|
||||
if (m_timeInfo.expires() != value) {
|
||||
m_timeInfo.setExpires(value);
|
||||
if (m_data.timeInfo.expires() != value) {
|
||||
m_data.timeInfo.setExpires(value);
|
||||
updateTimeinfo();
|
||||
Q_EMIT modified();
|
||||
}
|
||||
@@ -278,8 +285,8 @@ void Group::setExpires(bool value)
|
||||
|
||||
void Group::setExpiryTime(const QDateTime& dateTime)
|
||||
{
|
||||
if (m_timeInfo.expiryTime() != dateTime) {
|
||||
m_timeInfo.setExpiryTime(dateTime);
|
||||
if (m_data.timeInfo.expiryTime() != dateTime) {
|
||||
m_data.timeInfo.setExpiryTime(dateTime);
|
||||
updateTimeinfo();
|
||||
Q_EMIT modified();
|
||||
}
|
||||
@@ -347,7 +354,7 @@ void Group::setParent(Group* parent, int index)
|
||||
}
|
||||
|
||||
if (m_updateTimeinfo) {
|
||||
m_timeInfo.setLocationChanged(Tools::currentDateTimeUtc());
|
||||
m_data.timeInfo.setLocationChanged(Tools::currentDateTimeUtc());
|
||||
}
|
||||
|
||||
Q_EMIT modified();
|
||||
@@ -436,6 +443,79 @@ QList<const Group*> Group::groupsRecursive(bool includeSelf) const
|
||||
return groupList;
|
||||
}
|
||||
|
||||
QSet<Uuid> Group::customIconsRecursive() const
|
||||
{
|
||||
QSet<Uuid> result;
|
||||
|
||||
if (!iconUuid().isNull()) {
|
||||
result.insert(iconUuid());
|
||||
}
|
||||
|
||||
Q_FOREACH (Entry* entry, entriesRecursive(true)) {
|
||||
if (!entry->iconUuid().isNull()) {
|
||||
result.insert(entry->iconUuid());
|
||||
}
|
||||
}
|
||||
|
||||
Q_FOREACH (Group* group, m_children) {
|
||||
result.unite(group->customIconsRecursive());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Group* Group::clone(Entry::CloneFlags entryFlags) const
|
||||
{
|
||||
Group* clonedGroup = new Group();
|
||||
|
||||
clonedGroup->setUpdateTimeinfo(false);
|
||||
|
||||
clonedGroup->setUuid(Uuid::random());
|
||||
clonedGroup->m_data = m_data;
|
||||
|
||||
Q_FOREACH (Entry* entry, entries()) {
|
||||
Entry* clonedEntry = entry->clone(entryFlags);
|
||||
clonedEntry->setGroup(clonedGroup);
|
||||
}
|
||||
|
||||
Q_FOREACH (Group* groupChild, children()) {
|
||||
Group* clonedGroupChild = groupChild->clone();
|
||||
clonedGroupChild->setParent(clonedGroup);
|
||||
}
|
||||
|
||||
clonedGroup->setUpdateTimeinfo(true);
|
||||
|
||||
QDateTime now = Tools::currentDateTimeUtc();
|
||||
clonedGroup->m_data.timeInfo.setCreationTime(now);
|
||||
clonedGroup->m_data.timeInfo.setLastModificationTime(now);
|
||||
clonedGroup->m_data.timeInfo.setLastAccessTime(now);
|
||||
clonedGroup->m_data.timeInfo.setLocationChanged(now);
|
||||
|
||||
return clonedGroup;
|
||||
}
|
||||
|
||||
void Group::copyDataFrom(const Group* other)
|
||||
{
|
||||
m_data = other->m_data;
|
||||
m_lastTopVisibleEntry = other->m_lastTopVisibleEntry;
|
||||
}
|
||||
|
||||
Database* Group::exportToDb()
|
||||
{
|
||||
Q_ASSERT(database());
|
||||
|
||||
Database* db = new Database();
|
||||
Group* clonedGroup = clone(Entry::CloneNewUuid | Entry::CloneIncludeHistory);
|
||||
clonedGroup->setParent(db->rootGroup());
|
||||
|
||||
QSet<Uuid> customIcons = customIconsRecursive();
|
||||
db->metadata()->copyCustomIcons(customIcons, database()->metadata());
|
||||
|
||||
db->copyAttributesFrom(database());
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
void Group::addEntry(Entry* entry)
|
||||
{
|
||||
Q_ASSERT(entry);
|
||||
@@ -551,7 +631,7 @@ QList<Entry*> Group::search(const QString& searchTerm, Qt::CaseSensitivity caseS
|
||||
|
||||
bool Group::includeInSearch(bool resolveInherit)
|
||||
{
|
||||
switch (m_searchingEnabled) {
|
||||
switch (m_data.searchingEnabled) {
|
||||
case Inherit:
|
||||
if (!m_parent) {
|
||||
return true;
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#ifndef KEEPASSX_GROUP_H
|
||||
#define KEEPASSX_GROUP_H
|
||||
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QImage>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QPixmapCache>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPointer>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
@@ -35,6 +35,19 @@ class Group : public QObject
|
||||
public:
|
||||
enum TriState { Inherit, Enable, Disable };
|
||||
|
||||
struct GroupData
|
||||
{
|
||||
QString name;
|
||||
QString notes;
|
||||
int iconNumber;
|
||||
Uuid customIcon;
|
||||
TimeInfo timeInfo;
|
||||
bool isExpanded;
|
||||
QString defaultAutoTypeSequence;
|
||||
Group::TriState autoTypeEnabled;
|
||||
Group::TriState searchingEnabled;
|
||||
};
|
||||
|
||||
Group();
|
||||
~Group();
|
||||
|
||||
@@ -86,6 +99,17 @@ public:
|
||||
const QList<Entry*>& entries() const;
|
||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
||||
QSet<Uuid> customIconsRecursive() const;
|
||||
/**
|
||||
* Creates a duplicate of this group including all child entries and groups.
|
||||
* The exceptions are that the returned group doesn't have a parent group
|
||||
* and all TimeInfo attributes are set to the current time.
|
||||
* Note that you need to copy the custom icons manually when inserting the
|
||||
* new group into another database.
|
||||
*/
|
||||
Group* clone(Entry::CloneFlags entryFlags = Entry::CloneNewUuid | Entry::CloneResetTimeInfo) const;
|
||||
void copyDataFrom(const Group* other);
|
||||
Database* exportToDb();
|
||||
|
||||
QList<Entry*> search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
|
||||
bool resolveInherit = true);
|
||||
@@ -127,15 +151,7 @@ private:
|
||||
|
||||
QPointer<Database> m_db;
|
||||
Uuid m_uuid;
|
||||
QString m_name;
|
||||
QString m_notes;
|
||||
int m_iconNumber;
|
||||
Uuid m_customIcon;
|
||||
TimeInfo m_timeInfo;
|
||||
bool m_isExpanded;
|
||||
QString m_defaultAutoTypeSequence;
|
||||
TriState m_autoTypeEnabled;
|
||||
TriState m_searchingEnabled;
|
||||
GroupData m_data;
|
||||
QPointer<Entry> m_lastTopVisibleEntry;
|
||||
QList<Group*> m_children;
|
||||
QList<Entry*> m_entries;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_LISTDELETER_H
|
||||
#define KEEPASSX_LISTDELETER_H
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QList>
|
||||
|
||||
template <typename T>
|
||||
class ListDeleter
|
||||
|
||||
@@ -26,25 +26,26 @@ const int Metadata::DefaultHistoryMaxSize = 6 * 1024 * 1024;
|
||||
|
||||
Metadata::Metadata(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_generator("KeePassX")
|
||||
, m_maintenanceHistoryDays(365)
|
||||
, m_protectTitle(false)
|
||||
, m_protectUsername(false)
|
||||
, m_protectPassword(true)
|
||||
, m_protectUrl(false)
|
||||
, m_protectNotes(false)
|
||||
// , m_autoEnableVisualHiding(false)
|
||||
, m_recycleBinEnabled(true)
|
||||
, m_masterKeyChangeRec(-1)
|
||||
, m_masterKeyChangeForce(-1)
|
||||
, m_historyMaxItems(DefaultHistoryMaxItems)
|
||||
, m_historyMaxSize(DefaultHistoryMaxSize)
|
||||
, m_updateDatetime(true)
|
||||
{
|
||||
m_data.generator = "KeePassX";
|
||||
m_data.maintenanceHistoryDays = 365;
|
||||
m_data.masterKeyChangeRec = -1;
|
||||
m_data.masterKeyChangeForce = -1;
|
||||
m_data.historyMaxItems = DefaultHistoryMaxItems;
|
||||
m_data.historyMaxSize = DefaultHistoryMaxSize;
|
||||
m_data.recycleBinEnabled = true;
|
||||
m_data.protectTitle = false;
|
||||
m_data.protectUsername = false;
|
||||
m_data.protectPassword = true;
|
||||
m_data.protectUrl = false;
|
||||
m_data.protectNotes = false;
|
||||
// m_data.autoEnableVisualHiding = false;
|
||||
|
||||
QDateTime now = Tools::currentDateTimeUtc();
|
||||
m_nameChanged = now;
|
||||
m_descriptionChanged = now;
|
||||
m_defaultUserNameChanged = now;
|
||||
m_data.nameChanged = now;
|
||||
m_data.descriptionChanged = now;
|
||||
m_data.defaultUserNameChanged = now;
|
||||
m_recycleBinChanged = now;
|
||||
m_entryTemplatesGroupChanged = now;
|
||||
m_masterKeyChanged = now;
|
||||
@@ -81,74 +82,79 @@ void Metadata::setUpdateDatetime(bool value)
|
||||
m_updateDatetime = value;
|
||||
}
|
||||
|
||||
void Metadata::copyAttributesFrom(const Metadata* other)
|
||||
{
|
||||
m_data = other->m_data;
|
||||
}
|
||||
|
||||
QString Metadata::generator() const
|
||||
{
|
||||
return m_generator;
|
||||
return m_data.generator;
|
||||
}
|
||||
|
||||
QString Metadata::name() const
|
||||
{
|
||||
return m_name;
|
||||
return m_data.name;
|
||||
}
|
||||
|
||||
QDateTime Metadata::nameChanged() const
|
||||
{
|
||||
return m_nameChanged;
|
||||
return m_data.nameChanged;
|
||||
}
|
||||
|
||||
QString Metadata::description() const
|
||||
{
|
||||
return m_description;
|
||||
return m_data.description;
|
||||
}
|
||||
|
||||
QDateTime Metadata::descriptionChanged() const
|
||||
{
|
||||
return m_descriptionChanged;
|
||||
return m_data.descriptionChanged;
|
||||
}
|
||||
|
||||
QString Metadata::defaultUserName() const
|
||||
{
|
||||
return m_defaultUserName;
|
||||
return m_data.defaultUserName;
|
||||
}
|
||||
|
||||
QDateTime Metadata::defaultUserNameChanged() const
|
||||
{
|
||||
return m_defaultUserNameChanged;
|
||||
return m_data.defaultUserNameChanged;
|
||||
}
|
||||
|
||||
int Metadata::maintenanceHistoryDays() const
|
||||
{
|
||||
return m_maintenanceHistoryDays;
|
||||
return m_data.maintenanceHistoryDays;
|
||||
}
|
||||
|
||||
QColor Metadata::color() const
|
||||
{
|
||||
return m_color;
|
||||
return m_data.color;
|
||||
}
|
||||
|
||||
bool Metadata::protectTitle() const
|
||||
{
|
||||
return m_protectTitle;
|
||||
return m_data.protectTitle;
|
||||
}
|
||||
|
||||
bool Metadata::protectUsername() const
|
||||
{
|
||||
return m_protectUsername;
|
||||
return m_data.protectUsername;
|
||||
}
|
||||
|
||||
bool Metadata::protectPassword() const
|
||||
{
|
||||
return m_protectPassword;
|
||||
return m_data.protectPassword;
|
||||
}
|
||||
|
||||
bool Metadata::protectUrl() const
|
||||
{
|
||||
return m_protectUrl;
|
||||
return m_data.protectUrl;
|
||||
}
|
||||
|
||||
bool Metadata::protectNotes() const
|
||||
{
|
||||
return m_protectNotes;
|
||||
return m_data.protectNotes;
|
||||
}
|
||||
|
||||
/*bool Metadata::autoEnableVisualHiding() const
|
||||
@@ -178,7 +184,7 @@ QList<Uuid> Metadata::customIconsOrder() const
|
||||
|
||||
bool Metadata::recycleBinEnabled() const
|
||||
{
|
||||
return m_recycleBinEnabled;
|
||||
return m_data.recycleBinEnabled;
|
||||
}
|
||||
|
||||
Group* Metadata::recycleBin()
|
||||
@@ -223,22 +229,22 @@ QDateTime Metadata::masterKeyChanged() const
|
||||
|
||||
int Metadata::masterKeyChangeRec() const
|
||||
{
|
||||
return m_masterKeyChangeRec;
|
||||
return m_data.masterKeyChangeRec;
|
||||
}
|
||||
|
||||
int Metadata::masterKeyChangeForce() const
|
||||
{
|
||||
return m_masterKeyChangeForce;
|
||||
return m_data.masterKeyChangeForce;
|
||||
}
|
||||
|
||||
int Metadata::historyMaxItems() const
|
||||
{
|
||||
return m_historyMaxItems;
|
||||
return m_data.historyMaxItems;
|
||||
}
|
||||
|
||||
int Metadata::historyMaxSize() const
|
||||
{
|
||||
return m_historyMaxSize;
|
||||
return m_data.historyMaxSize;
|
||||
}
|
||||
|
||||
QHash<QString, QString> Metadata::customFields() const
|
||||
@@ -248,12 +254,12 @@ QHash<QString, QString> Metadata::customFields() const
|
||||
|
||||
void Metadata::setGenerator(const QString& value)
|
||||
{
|
||||
set(m_generator, value);
|
||||
set(m_data.generator, value);
|
||||
}
|
||||
|
||||
void Metadata::setName(const QString& value)
|
||||
{
|
||||
if (set(m_name, value, m_nameChanged)) {
|
||||
if (set(m_data.name, value, m_data.nameChanged)) {
|
||||
Q_EMIT nameTextChanged();
|
||||
}
|
||||
}
|
||||
@@ -261,64 +267,64 @@ void Metadata::setName(const QString& value)
|
||||
void Metadata::setNameChanged(const QDateTime& value)
|
||||
{
|
||||
Q_ASSERT(value.timeSpec() == Qt::UTC);
|
||||
m_nameChanged = value;
|
||||
m_data.nameChanged = value;
|
||||
}
|
||||
|
||||
void Metadata::setDescription(const QString& value)
|
||||
{
|
||||
set(m_description, value, m_descriptionChanged);
|
||||
set(m_data.description, value, m_data.descriptionChanged);
|
||||
}
|
||||
|
||||
void Metadata::setDescriptionChanged(const QDateTime& value)
|
||||
{
|
||||
Q_ASSERT(value.timeSpec() == Qt::UTC);
|
||||
m_descriptionChanged = value;
|
||||
m_data.descriptionChanged = value;
|
||||
}
|
||||
|
||||
void Metadata::setDefaultUserName(const QString& value)
|
||||
{
|
||||
set(m_defaultUserName, value, m_defaultUserNameChanged);
|
||||
set(m_data.defaultUserName, value, m_data.defaultUserNameChanged);
|
||||
}
|
||||
|
||||
void Metadata::setDefaultUserNameChanged(const QDateTime& value)
|
||||
{
|
||||
Q_ASSERT(value.timeSpec() == Qt::UTC);
|
||||
m_defaultUserNameChanged = value;
|
||||
m_data.defaultUserNameChanged = value;
|
||||
}
|
||||
|
||||
void Metadata::setMaintenanceHistoryDays(int value)
|
||||
{
|
||||
set(m_maintenanceHistoryDays, value);
|
||||
set(m_data.maintenanceHistoryDays, value);
|
||||
}
|
||||
|
||||
void Metadata::setColor(const QColor& value)
|
||||
{
|
||||
set(m_color, value);
|
||||
set(m_data.color, value);
|
||||
}
|
||||
|
||||
void Metadata::setProtectTitle(bool value)
|
||||
{
|
||||
set(m_protectTitle, value);
|
||||
set(m_data.protectTitle, value);
|
||||
}
|
||||
|
||||
void Metadata::setProtectUsername(bool value)
|
||||
{
|
||||
set(m_protectUsername, value);
|
||||
set(m_data.protectUsername, value);
|
||||
}
|
||||
|
||||
void Metadata::setProtectPassword(bool value)
|
||||
{
|
||||
set(m_protectPassword, value);
|
||||
set(m_data.protectPassword, value);
|
||||
}
|
||||
|
||||
void Metadata::setProtectUrl(bool value)
|
||||
{
|
||||
set(m_protectUrl, value);
|
||||
set(m_data.protectUrl, value);
|
||||
}
|
||||
|
||||
void Metadata::setProtectNotes(bool value)
|
||||
{
|
||||
set(m_protectNotes, value);
|
||||
set(m_data.protectNotes, value);
|
||||
}
|
||||
|
||||
/*void Metadata::setAutoEnableVisualHiding(bool value)
|
||||
@@ -348,9 +354,20 @@ void Metadata::removeCustomIcon(const Uuid& uuid)
|
||||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
void Metadata::copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata)
|
||||
{
|
||||
Q_FOREACH (const Uuid& uuid, iconList) {
|
||||
Q_ASSERT(otherMetadata->containsCustomIcon(uuid));
|
||||
|
||||
if (!containsCustomIcon(uuid) && otherMetadata->containsCustomIcon(uuid)) {
|
||||
addCustomIcon(uuid, otherMetadata->customIcon(uuid));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Metadata::setRecycleBinEnabled(bool value)
|
||||
{
|
||||
set(m_recycleBinEnabled, value);
|
||||
set(m_data.recycleBinEnabled, value);
|
||||
}
|
||||
|
||||
void Metadata::setRecycleBin(Group* group)
|
||||
@@ -393,22 +410,22 @@ void Metadata::setMasterKeyChanged(const QDateTime& value)
|
||||
|
||||
void Metadata::setMasterKeyChangeRec(int value)
|
||||
{
|
||||
set(m_masterKeyChangeRec, value);
|
||||
set(m_data.masterKeyChangeRec, value);
|
||||
}
|
||||
|
||||
void Metadata::setMasterKeyChangeForce(int value)
|
||||
{
|
||||
set(m_masterKeyChangeForce, value);
|
||||
set(m_data.masterKeyChangeForce, value);
|
||||
}
|
||||
|
||||
void Metadata::setHistoryMaxItems(int value)
|
||||
{
|
||||
set(m_historyMaxItems, value);
|
||||
set(m_data.historyMaxItems, value);
|
||||
}
|
||||
|
||||
void Metadata::setHistoryMaxSize(int value)
|
||||
{
|
||||
set(m_historyMaxSize, value);
|
||||
set(m_data.historyMaxSize, value);
|
||||
}
|
||||
|
||||
void Metadata::addCustomField(const QString& key, const QString& value)
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#ifndef KEEPASSX_METADATA_H
|
||||
#define KEEPASSX_METADATA_H
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QImage>
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QImage>
|
||||
#include <QPointer>
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "core/Uuid.h"
|
||||
@@ -37,6 +37,31 @@ class Metadata : public QObject
|
||||
public:
|
||||
explicit Metadata(QObject* parent = Q_NULLPTR);
|
||||
|
||||
struct MetadataData
|
||||
{
|
||||
QString generator;
|
||||
QString name;
|
||||
QDateTime nameChanged;
|
||||
QString description;
|
||||
QDateTime descriptionChanged;
|
||||
QString defaultUserName;
|
||||
QDateTime defaultUserNameChanged;
|
||||
int maintenanceHistoryDays;
|
||||
QColor color;
|
||||
bool recycleBinEnabled;
|
||||
int historyMaxItems;
|
||||
int historyMaxSize;
|
||||
int masterKeyChangeRec;
|
||||
int masterKeyChangeForce;
|
||||
|
||||
bool protectTitle;
|
||||
bool protectUsername;
|
||||
bool protectPassword;
|
||||
bool protectUrl;
|
||||
bool protectNotes;
|
||||
// bool autoEnableVisualHiding;
|
||||
};
|
||||
|
||||
QString generator() const;
|
||||
QString name() const;
|
||||
QDateTime nameChanged() const;
|
||||
@@ -91,6 +116,7 @@ public:
|
||||
// void setAutoEnableVisualHiding(bool value);
|
||||
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
||||
void removeCustomIcon(const Uuid& uuid);
|
||||
void copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata);
|
||||
void setRecycleBinEnabled(bool value);
|
||||
void setRecycleBin(Group* group);
|
||||
void setRecycleBinChanged(const QDateTime& value);
|
||||
@@ -106,6 +132,14 @@ public:
|
||||
void addCustomField(const QString& key, const QString& value);
|
||||
void removeCustomField(const QString& key);
|
||||
void setUpdateDatetime(bool value);
|
||||
/*
|
||||
* Copy all attributes from other except:
|
||||
* - Group pointers/uuids
|
||||
* - Master key changed date
|
||||
* - Custom icons
|
||||
* - Custom fields
|
||||
*/
|
||||
void copyAttributesFrom(const Metadata* other);
|
||||
|
||||
Q_SIGNALS:
|
||||
void nameTextChanged();
|
||||
@@ -115,27 +149,11 @@ private:
|
||||
template <class P, class V> bool set(P& property, const V& value);
|
||||
template <class P, class V> bool set(P& property, const V& value, QDateTime& dateTime);
|
||||
|
||||
QString m_generator;
|
||||
QString m_name;
|
||||
QDateTime m_nameChanged;
|
||||
QString m_description;
|
||||
QDateTime m_descriptionChanged;
|
||||
QString m_defaultUserName;
|
||||
QDateTime m_defaultUserNameChanged;
|
||||
int m_maintenanceHistoryDays;
|
||||
QColor m_color;
|
||||
|
||||
bool m_protectTitle;
|
||||
bool m_protectUsername;
|
||||
bool m_protectPassword;
|
||||
bool m_protectUrl;
|
||||
bool m_protectNotes;
|
||||
// bool m_autoEnableVisualHiding;
|
||||
MetadataData m_data;
|
||||
|
||||
QHash<Uuid, QImage> m_customIcons;
|
||||
QList<Uuid> m_customIconsOrder;
|
||||
|
||||
bool m_recycleBinEnabled;
|
||||
QPointer<Group> m_recycleBin;
|
||||
QDateTime m_recycleBinChanged;
|
||||
QPointer<Group> m_entryTemplatesGroup;
|
||||
@@ -144,10 +162,6 @@ private:
|
||||
QPointer<Group> m_lastTopVisibleGroup;
|
||||
|
||||
QDateTime m_masterKeyChanged;
|
||||
int m_masterKeyChangeRec;
|
||||
int m_masterKeyChangeForce;
|
||||
int m_historyMaxItems;
|
||||
int m_historyMaxSize;
|
||||
|
||||
QHash<QString, QString> m_customFields;
|
||||
|
||||
|
||||
@@ -40,20 +40,20 @@ QString PasswordGenerator::generatePassword(int length,
|
||||
|
||||
if (flags & CharFromEveryGroup) {
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
int pos = Random::randomUInt(groups[i].size());
|
||||
int pos = randomGen()->randomUInt(groups[i].size());
|
||||
|
||||
password.append(groups[i][pos]);
|
||||
}
|
||||
|
||||
for (int i = groups.size(); i < length; i++) {
|
||||
int pos = Random::randomUInt(passwordChars.size());
|
||||
int pos = randomGen()->randomUInt(passwordChars.size());
|
||||
|
||||
password.append(passwordChars[pos]);
|
||||
}
|
||||
|
||||
// shuffle chars
|
||||
for (int i = (password.size() - 1); i >= 1; i--) {
|
||||
int j = Random::randomUInt(i + 1);
|
||||
int j = randomGen()->randomUInt(i + 1);
|
||||
|
||||
QChar tmp = password[i];
|
||||
password[i] = password[j];
|
||||
@@ -62,7 +62,7 @@ QString PasswordGenerator::generatePassword(int length,
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < length; i++) {
|
||||
int pos = Random::randomUInt(passwordChars.size());
|
||||
int pos = randomGen()->randomUInt(passwordChars.size());
|
||||
|
||||
password.append(passwordChars[pos]);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef KEEPASSX_PASSWORDGENERATOR_H
|
||||
#define KEEPASSX_PASSWORDGENERATOR_H
|
||||
|
||||
#include <QtCore/QFlags>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QVector>
|
||||
#include <QFlags>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_SIGNALMULTIPLEXER_H
|
||||
#define KEEPASSX_SIGNALMULTIPLEXER_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "TimeDelta.h"
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QDateTime>
|
||||
|
||||
QDateTime operator+(const QDateTime& dateTime, const TimeDelta& delta) {
|
||||
return dateTime.addDays(delta.getDays())
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_TIMEDELTA_H
|
||||
#define KEEPASSX_TIMEDELTA_H
|
||||
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QMetaType>
|
||||
|
||||
class QDateTime;
|
||||
class TimeDelta;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_TIMEINFO_H
|
||||
#define KEEPASSX_TIMEINFO_H
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QDateTime>
|
||||
|
||||
class TimeInfo
|
||||
{
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
|
||||
#include "Tools.h"
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtCore/QLocale>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtGui/QImageReader>
|
||||
#include <QCoreApplication>
|
||||
#include <QImageReader>
|
||||
#include <QIODevice>
|
||||
#include <QLocale>
|
||||
#include <QStringList>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include <QElapsedTimer>
|
||||
#else
|
||||
#include <QtCore/QTime>
|
||||
#include <QTime>
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -141,7 +141,7 @@ QString imageReaderFilter()
|
||||
}
|
||||
}
|
||||
|
||||
formatsStringList.append("*." + QString::fromAscii(format).toLower());
|
||||
formatsStringList.append("*." + QString::fromLatin1(format).toLower());
|
||||
}
|
||||
|
||||
return formatsStringList.join(" ");
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef KEEPASSX_TOOLS_H
|
||||
#define KEEPASSX_TOOLS_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QDateTime>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "Uuid.h"
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QHash>
|
||||
|
||||
#include "crypto/Random.h"
|
||||
|
||||
@@ -37,17 +37,17 @@ Uuid::Uuid(const QByteArray& data)
|
||||
|
||||
Uuid Uuid::random()
|
||||
{
|
||||
return Uuid(Random::randomArray(Length));
|
||||
return Uuid(randomGen()->randomArray(Length));
|
||||
}
|
||||
|
||||
QString Uuid::toBase64() const
|
||||
{
|
||||
return QString::fromAscii(m_data.toBase64());
|
||||
return QString::fromLatin1(m_data.toBase64());
|
||||
}
|
||||
|
||||
QString Uuid::toHex() const
|
||||
{
|
||||
return QString::fromAscii(m_data.toHex());
|
||||
return QString::fromLatin1(m_data.toHex());
|
||||
}
|
||||
|
||||
QByteArray Uuid::toByteArray() const
|
||||
@@ -85,7 +85,7 @@ bool Uuid::operator!=(const Uuid& other) const
|
||||
|
||||
Uuid Uuid::fromBase64(const QString& str)
|
||||
{
|
||||
QByteArray data = QByteArray::fromBase64(str.toAscii());
|
||||
QByteArray data = QByteArray::fromBase64(str.toLatin1());
|
||||
return Uuid(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_UUID_H
|
||||
#define KEEPASSX_UUID_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QString>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
class Uuid
|
||||
{
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
#include "qsavefile.h"
|
||||
#include "qsavefile_p.h"
|
||||
|
||||
#include <QtCore/QAbstractFileEngine>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QAbstractFileEngine>
|
||||
#include <QFileInfo>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
QSaveFilePrivate::QSaveFilePrivate()
|
||||
: tempFile(0), error(QFile::NoError)
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
#ifndef QSAVEFILE_H
|
||||
#define QSAVEFILE_H
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QString>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
|
||||
#ifdef open
|
||||
#error qsavefile.h must be included before any header file that defines open
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/QTemporaryFile>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
class QSaveFilePrivate
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "Crypto.h"
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
#include <QMutex>
|
||||
|
||||
#include <gcrypt.h>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_CRYPTOHASH_H
|
||||
#define KEEPASSX_CRYPTOHASH_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QByteArray>
|
||||
|
||||
class CryptoHashPrivate;
|
||||
|
||||
|
||||
@@ -21,9 +21,17 @@
|
||||
|
||||
#include "crypto/Crypto.h"
|
||||
|
||||
class RandomBackendGcrypt : public RandomBackend
|
||||
{
|
||||
public:
|
||||
void randomize(void* data, int len) Q_DECL_OVERRIDE;
|
||||
};
|
||||
|
||||
Random* Random::m_instance(Q_NULLPTR);
|
||||
|
||||
void Random::randomize(QByteArray& ba)
|
||||
{
|
||||
randomize(ba.data(), ba.size());
|
||||
m_backend->randomize(ba.data(), ba.size());
|
||||
}
|
||||
|
||||
QByteArray Random::randomArray(int len)
|
||||
@@ -38,8 +46,18 @@ QByteArray Random::randomArray(int len)
|
||||
|
||||
quint32 Random::randomUInt(quint32 limit)
|
||||
{
|
||||
Q_ASSERT(limit != 0);
|
||||
Q_ASSERT(limit <= QUINT32_MAX);
|
||||
|
||||
quint32 rand;
|
||||
randomize(&rand, 4);
|
||||
const quint32 ceil = QUINT32_MAX - (QUINT32_MAX % limit) - 1;
|
||||
|
||||
// To avoid modulo bias:
|
||||
// Make sure rand is below the largest number where rand%limit==0
|
||||
do {
|
||||
m_backend->randomize(&rand, 4);
|
||||
} while (rand > ceil);
|
||||
|
||||
return (rand % limit);
|
||||
}
|
||||
|
||||
@@ -48,13 +66,32 @@ quint32 Random::randomUIntRange(quint32 min, quint32 max)
|
||||
return min + randomUInt(max - min);
|
||||
}
|
||||
|
||||
void Random::randomize(void* data, int len)
|
||||
Random* Random::instance()
|
||||
{
|
||||
if (!m_instance) {
|
||||
m_instance = new Random(new RandomBackendGcrypt());
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void Random::createWithBackend(RandomBackend* backend)
|
||||
{
|
||||
Q_ASSERT(backend);
|
||||
Q_ASSERT(!m_instance);
|
||||
|
||||
m_instance = new Random(backend);
|
||||
}
|
||||
|
||||
Random::Random(RandomBackend* backend)
|
||||
: m_backend(backend)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void RandomBackendGcrypt::randomize(void* data, int len)
|
||||
{
|
||||
Q_ASSERT(Crypto::initalized());
|
||||
|
||||
gcry_randomize(data, len, GCRY_STRONG_RANDOM);
|
||||
}
|
||||
|
||||
Random::Random()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -18,27 +18,46 @@
|
||||
#ifndef KEEPASSX_RANDOM_H
|
||||
#define KEEPASSX_RANDOM_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QByteArray>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class RandomBackend
|
||||
{
|
||||
public:
|
||||
virtual void randomize(void* data, int len) = 0;
|
||||
virtual ~RandomBackend() {}
|
||||
};
|
||||
|
||||
class Random
|
||||
{
|
||||
public:
|
||||
static void randomize(QByteArray& ba);
|
||||
static QByteArray randomArray(int len);
|
||||
void randomize(QByteArray& ba);
|
||||
QByteArray randomArray(int len);
|
||||
|
||||
/**
|
||||
* Generate a random quint32 in the range [0, @p limit)
|
||||
*/
|
||||
static quint32 randomUInt(quint32 limit);
|
||||
quint32 randomUInt(quint32 limit);
|
||||
|
||||
/**
|
||||
* Generate a random quint32 in the range [@p min, @p max)
|
||||
*/
|
||||
static quint32 randomUIntRange(quint32 min, quint32 max);
|
||||
quint32 randomUIntRange(quint32 min, quint32 max);
|
||||
|
||||
static Random* instance();
|
||||
static void createWithBackend(RandomBackend* backend);
|
||||
|
||||
private:
|
||||
static void randomize(void* data, int len);
|
||||
Random();
|
||||
explicit Random(RandomBackend* backend);
|
||||
|
||||
QScopedPointer<RandomBackend> m_backend;
|
||||
static Random* m_instance;
|
||||
|
||||
Q_DISABLE_COPY(Random)
|
||||
};
|
||||
|
||||
inline Random* randomGen() {
|
||||
return Random::instance();
|
||||
}
|
||||
|
||||
#endif // KEEPASSX_RANDOM_H
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_SYMMETRICCIPHER_H
|
||||
#define KEEPASSX_SYMMETRICCIPHER_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QByteArray>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "crypto/SymmetricCipherBackend.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_SYMMETRICCIPHERBACKEND_H
|
||||
#define KEEPASSX_SYMMETRICCIPHERBACKEND_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QByteArray>
|
||||
|
||||
class SymmetricCipherBackend
|
||||
{
|
||||
|
||||
@@ -24,6 +24,7 @@ SymmetricCipherGcrypt::SymmetricCipherGcrypt(SymmetricCipher::Algorithm algo, Sy
|
||||
: m_algo(gcryptAlgo(algo))
|
||||
, m_mode(gcryptMode(mode))
|
||||
, m_direction(direction)
|
||||
, m_blockSize(-1)
|
||||
{
|
||||
Q_ASSERT(Crypto::initalized());
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_KEEPASS1_H
|
||||
#define KEEPASSX_KEEPASS1_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace KeePass1
|
||||
{
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include "KeePass1Reader.h"
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QTextCodec>
|
||||
#include <QtGui/QImage>
|
||||
#include <QFile>
|
||||
#include <QImage>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Endian.h"
|
||||
@@ -56,6 +56,9 @@ KeePass1Reader::KeePass1Reader()
|
||||
Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& password,
|
||||
QIODevice* keyfileDevice)
|
||||
{
|
||||
m_error = false;
|
||||
m_errorStr.clear();
|
||||
|
||||
QByteArray keyfileData;
|
||||
FileKey newFileKey;
|
||||
|
||||
@@ -63,13 +66,16 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
keyfileData = readKeyfile(keyfileDevice);
|
||||
|
||||
if (keyfileData.isEmpty()) {
|
||||
raiseError(tr("Unable to read keyfile.").append("\n").append(keyfileDevice->errorString()));
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
if (!keyfileDevice->seek(0)) {
|
||||
raiseError(tr("Unable to read keyfile.").append("\n").append(keyfileDevice->errorString()));
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
if (!newFileKey.load(keyfileDevice)) {
|
||||
raiseError(tr("Unable to read keyfile.").append("\n").append(keyfileDevice->errorString()));
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
@@ -79,8 +85,6 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
m_db = db.data();
|
||||
m_tmpParent = tmpParent.data();
|
||||
m_device = device;
|
||||
m_error = false;
|
||||
m_errorStr = QString();
|
||||
|
||||
bool ok;
|
||||
|
||||
@@ -111,43 +115,43 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
|
||||
m_masterSeed = m_device->read(16);
|
||||
if (m_masterSeed.size() != 16) {
|
||||
// TODO: error
|
||||
raiseError("Unable to read master seed");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
m_encryptionIV = m_device->read(16);
|
||||
if (m_encryptionIV.size() != 16) {
|
||||
// TODO: error
|
||||
raiseError("Unable to read encryption IV");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
quint32 numGroups = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
// TODO: error
|
||||
raiseError("Invalid number of groups");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
quint32 numEntries = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
// TODO: error
|
||||
raiseError("Invalid number of entries");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
m_contentHashHeader = m_device->read(32);
|
||||
if (m_contentHashHeader.size() != 32) {
|
||||
// TODO: error
|
||||
raiseError("Invalid content hash size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
m_transformSeed = m_device->read(32);
|
||||
if (m_transformSeed.size() != 32) {
|
||||
// TODO: error
|
||||
raiseError("Invalid transform seed size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
m_transformRounds = Endian::readUInt32(m_device, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
// TODO: error
|
||||
raiseError("Invalid number of transform rounds");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
m_db->setTransformRounds(m_transformRounds);
|
||||
@@ -157,7 +161,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
QScopedPointer<SymmetricCipherStream> cipherStream(testKeys(password, keyfileData, contentPos));
|
||||
|
||||
if (!cipherStream) {
|
||||
// TODO: error
|
||||
raiseError("Unable to create cipher stream");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
@@ -180,6 +184,7 @@ Database* KeePass1Reader::readDatabase(QIODevice* device, const QString& passwor
|
||||
}
|
||||
|
||||
if (!constructGroupTree(groups)) {
|
||||
raiseError("Unable to construct group tree");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
@@ -337,7 +342,12 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
|
||||
cipherStream->reset();
|
||||
cipherStream->close();
|
||||
if (!m_device->seek(contentPos)) {
|
||||
// TODO: error
|
||||
QString msg = "unable to seek to content position";
|
||||
if (!m_device->errorString().isEmpty()) {
|
||||
msg.append("\n").append(m_device->errorString());
|
||||
}
|
||||
raiseError(msg);
|
||||
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
cipherStream->open(QIODevice::ReadOnly);
|
||||
@@ -355,6 +365,9 @@ SymmetricCipherStream* KeePass1Reader::testKeys(const QString& password, const Q
|
||||
|
||||
QByteArray KeePass1Reader::key(const QByteArray& password, const QByteArray& keyfileData)
|
||||
{
|
||||
Q_ASSERT(!m_masterSeed.isEmpty());
|
||||
Q_ASSERT(!m_transformSeed.isEmpty());
|
||||
|
||||
KeePass1Key key;
|
||||
key.setPassword(password);
|
||||
key.setKeyfileData(keyfileData);
|
||||
@@ -387,26 +400,31 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
group->setParent(m_tmpParent);
|
||||
|
||||
TimeInfo timeInfo;
|
||||
// TODO: make sure these are initalized
|
||||
quint32 groupId;
|
||||
quint32 groupLevel;
|
||||
|
||||
quint32 groupId = 0;
|
||||
quint32 groupLevel = 0;
|
||||
bool groupIdSet = false;
|
||||
bool groupLevelSet = false;
|
||||
|
||||
bool ok;
|
||||
bool reachedEnd = false;
|
||||
|
||||
do {
|
||||
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Invalid group field type number");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
||||
if (!ok) {
|
||||
raiseError("Invalid group field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
QByteArray fieldData = cipherStream->read(fieldSize);
|
||||
if (fieldData.size() != fieldSize) {
|
||||
// TODO: error
|
||||
raiseError("Read group field data doesn't match size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
@@ -416,9 +434,11 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
break;
|
||||
case 0x0001:
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Incorrect group id field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
groupIdSet = true;
|
||||
break;
|
||||
case 0x0002:
|
||||
group->setName(QString::fromUtf8(fieldData.constData()));
|
||||
@@ -426,6 +446,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
case 0x0003:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Incorrect group creation time field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
@@ -437,6 +458,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
case 0x0004:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Incorrect group modification time field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
@@ -448,7 +470,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
case 0x0005:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
return Q_NULLPTR;
|
||||
raiseError("Incorrect group access time field size");
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
@@ -459,7 +481,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
case 0x0006:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
return Q_NULLPTR;
|
||||
raiseError("Incorrect group expiry time field size");
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
if (dateTime.isValid()) {
|
||||
@@ -471,6 +493,7 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
case 0x0007:
|
||||
{
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Incorrect group icon field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
@@ -480,9 +503,11 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
case 0x0008:
|
||||
{
|
||||
if (fieldSize != 2) {
|
||||
raiseError("Incorrect group level field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
groupLevel = Endian::bytesToUInt16(fieldData, KeePass1::BYTEORDER);
|
||||
groupLevelSet = true;
|
||||
break;
|
||||
}
|
||||
case 0x0009:
|
||||
@@ -493,10 +518,16 @@ Group* KeePass1Reader::readGroup(QIODevice* cipherStream)
|
||||
break;
|
||||
default:
|
||||
// invalid field
|
||||
raiseError("Invalid group field type");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
} while (!reachedEnd);
|
||||
|
||||
if (!groupIdSet || !groupLevelSet) {
|
||||
raiseError("Missing group id or level");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
group->setUuid(Uuid::random());
|
||||
group->setTimeInfo(timeInfo);
|
||||
m_groupIds.insert(groupId, group.data());
|
||||
@@ -519,17 +550,19 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
do {
|
||||
quint16 fieldType = Endian::readUInt16(cipherStream, KeePass1::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("Missing entry field type number");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
int fieldSize = static_cast<int>(Endian::readUInt32(cipherStream, KeePass1::BYTEORDER, &ok));
|
||||
if (!ok) {
|
||||
raiseError("Invalid entry field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
QByteArray fieldData = cipherStream->read(fieldSize);
|
||||
if (fieldData.size() != fieldSize) {
|
||||
// TODO: error
|
||||
raiseError("Read entry field data doesn't match size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
@@ -539,6 +572,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
break;
|
||||
case 0x0001:
|
||||
if (fieldSize != 16) {
|
||||
raiseError("Invalid entry uuid field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
m_entryUuids.insert(fieldData, entry.data());
|
||||
@@ -546,6 +580,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
case 0x0002:
|
||||
{
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Invalid entry group id field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
quint32 groupId = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
@@ -555,6 +590,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
case 0x0003:
|
||||
{
|
||||
if (fieldSize != 4) {
|
||||
raiseError("Invalid entry icon field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
quint32 iconNumber = Endian::bytesToUInt32(fieldData, KeePass1::BYTEORDER);
|
||||
@@ -579,6 +615,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
case 0x0009:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry creation time field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
@@ -590,6 +627,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
case 0x000A:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry modification time field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
@@ -601,6 +639,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
case 0x000B:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry creation time field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
@@ -612,6 +651,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
case 0x000C:
|
||||
{
|
||||
if (fieldSize != 5) {
|
||||
raiseError("Invalid entry expiry time field size");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
QDateTime dateTime = dateFromPackedStruct(fieldData);
|
||||
@@ -634,6 +674,7 @@ Entry* KeePass1Reader::readEntry(QIODevice* cipherStream)
|
||||
break;
|
||||
default:
|
||||
// invalid field
|
||||
raiseError("Invalid entry field type");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
} while (!reachedEnd);
|
||||
@@ -858,10 +899,10 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
|
||||
return true;
|
||||
}
|
||||
|
||||
void KeePass1Reader::raiseError(const QString& str)
|
||||
void KeePass1Reader::raiseError(const QString& errorMessage)
|
||||
{
|
||||
m_error = true;
|
||||
m_errorStr = str;
|
||||
m_errorStr = errorMessage;
|
||||
}
|
||||
|
||||
QDateTime KeePass1Reader::dateFromPackedStruct(const QByteArray& data)
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef KEEPASSX_KEEPASS1READER_H
|
||||
#define KEEPASSX_KEEPASS1READER_H
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
|
||||
class Database;
|
||||
class Entry;
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
void parseMetaStream(const Entry* entry);
|
||||
bool parseGroupTreeState(const QByteArray& data);
|
||||
bool parseCustomIcons4(const QByteArray& data);
|
||||
void raiseError(const QString& str);
|
||||
void raiseError(const QString& errorMessage);
|
||||
static QByteArray readKeyfile(QIODevice* device);
|
||||
static QDateTime dateFromPackedStruct(const QByteArray& data);
|
||||
static bool isMetaStream(const Entry* entry);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_KEEPASS2_H
|
||||
#define KEEPASSX_KEEPASS2_H
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "core/Uuid.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_KEEPASS2RANDOMSTREAM_H
|
||||
#define KEEPASSX_KEEPASS2RANDOMSTREAM_H
|
||||
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QByteArray>
|
||||
|
||||
#include "crypto/SymmetricCipher.h"
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include "KeePass2Reader.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
#include <QIODevice>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Endian.h"
|
||||
@@ -33,8 +33,9 @@
|
||||
#include "streams/SymmetricCipherStream.h"
|
||||
|
||||
KeePass2Reader::KeePass2Reader()
|
||||
: m_error(false)
|
||||
, m_saveXml(false)
|
||||
{
|
||||
m_saveXml = false;
|
||||
}
|
||||
|
||||
Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& key)
|
||||
@@ -43,7 +44,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
||||
m_db = db.data();
|
||||
m_device = device;
|
||||
m_error = false;
|
||||
m_errorStr = QString();
|
||||
m_errorStr.clear();
|
||||
m_headerEnd = false;
|
||||
m_xmlData.clear();
|
||||
m_masterSeed.clear();
|
||||
@@ -83,11 +84,15 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
||||
|
||||
headerStream.close();
|
||||
|
||||
if (hasError()) {
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
// check if all required headers were present
|
||||
if (m_masterSeed.isEmpty() || m_transformSeed.isEmpty() || m_encryptionIV.isEmpty()
|
||||
|| m_streamStartBytes.isEmpty() || m_protectedStreamKey.isEmpty()
|
||||
|| m_db->cipher().isNull()) {
|
||||
raiseError("");
|
||||
raiseError("missing database headers");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
@@ -149,7 +154,7 @@ Database* KeePass2Reader::readDatabase(QIODevice* device, const CompositeKey& ke
|
||||
if (!xmlReader.headerHash().isEmpty()) {
|
||||
QByteArray headerHash = CryptoHash::hash(headerStream.storedData(), CryptoHash::Sha256);
|
||||
if (headerHash != xmlReader.headerHash()) {
|
||||
raiseError("");
|
||||
raiseError("Head doesn't match hash");
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
}
|
||||
@@ -195,17 +200,17 @@ QByteArray KeePass2Reader::xmlData()
|
||||
return m_xmlData;
|
||||
}
|
||||
|
||||
void KeePass2Reader::raiseError(const QString& str)
|
||||
void KeePass2Reader::raiseError(const QString& errorMessage)
|
||||
{
|
||||
m_error = true;
|
||||
m_errorStr = str;
|
||||
m_errorStr = errorMessage;
|
||||
}
|
||||
|
||||
bool KeePass2Reader::readHeaderField()
|
||||
{
|
||||
QByteArray fieldIDArray = m_headerStream->read(1);
|
||||
if (fieldIDArray.size() != 1) {
|
||||
raiseError("");
|
||||
raiseError("Invalid header id size");
|
||||
return false;
|
||||
}
|
||||
quint8 fieldID = fieldIDArray.at(0);
|
||||
@@ -213,7 +218,7 @@ bool KeePass2Reader::readHeaderField()
|
||||
bool ok;
|
||||
quint16 fieldLen = Endian::readUInt16(m_headerStream, KeePass2::BYTEORDER, &ok);
|
||||
if (!ok) {
|
||||
raiseError("");
|
||||
raiseError("Invalid header field length");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -221,7 +226,7 @@ bool KeePass2Reader::readHeaderField()
|
||||
if (fieldLen != 0) {
|
||||
fieldData = m_headerStream->read(fieldLen);
|
||||
if (fieldData.size() != fieldLen) {
|
||||
raiseError("");
|
||||
raiseError("Invalid header data length");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -278,13 +283,13 @@ bool KeePass2Reader::readHeaderField()
|
||||
void KeePass2Reader::setCipher(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != Uuid::Length) {
|
||||
raiseError("");
|
||||
raiseError("Invalid cipher uuid length");
|
||||
}
|
||||
else {
|
||||
Uuid uuid(data);
|
||||
|
||||
if (uuid != KeePass2::CIPHER_AES) {
|
||||
raiseError("");
|
||||
raiseError("Unsupported cipher");
|
||||
}
|
||||
else {
|
||||
m_db->setCipher(uuid);
|
||||
@@ -295,13 +300,13 @@ void KeePass2Reader::setCipher(const QByteArray& data)
|
||||
void KeePass2Reader::setCompressionFlags(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 4) {
|
||||
raiseError("");
|
||||
raiseError("Invalid compression flags length");
|
||||
}
|
||||
else {
|
||||
quint32 id = Endian::bytesToUInt32(data, KeePass2::BYTEORDER);
|
||||
|
||||
if (id > Database::CompressionAlgorithmMax) {
|
||||
raiseError("");
|
||||
raiseError("Unsupported compression algorithm");
|
||||
}
|
||||
else {
|
||||
m_db->setCompressionAlgo(static_cast<Database::CompressionAlgorithm>(id));
|
||||
@@ -312,7 +317,7 @@ void KeePass2Reader::setCompressionFlags(const QByteArray& data)
|
||||
void KeePass2Reader::setMasterSeed(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 32) {
|
||||
raiseError("");
|
||||
raiseError("Invalid master seed size");
|
||||
}
|
||||
else {
|
||||
m_masterSeed = data;
|
||||
@@ -322,7 +327,7 @@ void KeePass2Reader::setMasterSeed(const QByteArray& data)
|
||||
void KeePass2Reader::setTransformSeed(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 32) {
|
||||
raiseError("");
|
||||
raiseError("Invalid transform seed size");
|
||||
}
|
||||
else {
|
||||
m_transformSeed = data;
|
||||
@@ -332,7 +337,7 @@ void KeePass2Reader::setTransformSeed(const QByteArray& data)
|
||||
void KeePass2Reader::setTansformRounds(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 8) {
|
||||
raiseError("");
|
||||
raiseError("Invalid transform rounds size");
|
||||
}
|
||||
else {
|
||||
m_db->setTransformRounds(Endian::bytesToUInt64(data, KeePass2::BYTEORDER));
|
||||
@@ -342,7 +347,7 @@ void KeePass2Reader::setTansformRounds(const QByteArray& data)
|
||||
void KeePass2Reader::setEncryptionIV(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 16) {
|
||||
raiseError("");
|
||||
raiseError("Invalid encryption iv size");
|
||||
}
|
||||
else {
|
||||
m_encryptionIV = data;
|
||||
@@ -352,7 +357,7 @@ void KeePass2Reader::setEncryptionIV(const QByteArray& data)
|
||||
void KeePass2Reader::setProtectedStreamKey(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 32) {
|
||||
raiseError("");
|
||||
raiseError("Invalid stream key size");
|
||||
}
|
||||
else {
|
||||
m_protectedStreamKey = data;
|
||||
@@ -362,7 +367,7 @@ void KeePass2Reader::setProtectedStreamKey(const QByteArray& data)
|
||||
void KeePass2Reader::setStreamStartBytes(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 32) {
|
||||
raiseError("");
|
||||
raiseError("Invalid start bytes size");
|
||||
}
|
||||
else {
|
||||
m_streamStartBytes = data;
|
||||
@@ -372,13 +377,13 @@ void KeePass2Reader::setStreamStartBytes(const QByteArray& data)
|
||||
void KeePass2Reader::setInnerRandomStreamID(const QByteArray& data)
|
||||
{
|
||||
if (data.size() != 4) {
|
||||
raiseError("");
|
||||
raiseError("Invalid random stream id size");
|
||||
}
|
||||
else {
|
||||
quint32 id = Endian::bytesToUInt32(data, KeePass2::BYTEORDER);
|
||||
|
||||
if (id != KeePass2::Salsa20) {
|
||||
raiseError("");
|
||||
raiseError("Unsupported random stream algorithm");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_KEEPASS2READER_H
|
||||
#define KEEPASSX_KEEPASS2READER_H
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "keys/CompositeKey.h"
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
QByteArray xmlData();
|
||||
|
||||
private:
|
||||
void raiseError(const QString& str);
|
||||
void raiseError(const QString& errorMessage);
|
||||
|
||||
bool readHeaderField();
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include "KeePass2Writer.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
#include <QIODevice>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Endian.h"
|
||||
@@ -43,12 +43,12 @@ KeePass2Writer::KeePass2Writer()
|
||||
void KeePass2Writer::writeDatabase(QIODevice* device, Database* db)
|
||||
{
|
||||
m_error = false;
|
||||
m_errorStr = QString();
|
||||
m_errorStr.clear();
|
||||
|
||||
QByteArray masterSeed = Random::randomArray(32);
|
||||
QByteArray encryptionIV = Random::randomArray(16);
|
||||
QByteArray protectedStreamKey = Random::randomArray(32);
|
||||
QByteArray startBytes = Random::randomArray(32);
|
||||
QByteArray masterSeed = randomGen()->randomArray(32);
|
||||
QByteArray encryptionIV = randomGen()->randomArray(16);
|
||||
QByteArray protectedStreamKey = randomGen()->randomArray(32);
|
||||
QByteArray startBytes = randomGen()->randomArray(32);
|
||||
QByteArray endOfHeader = "\r\n\r\n";
|
||||
|
||||
CryptoHash hash(CryptoHash::Sha256);
|
||||
@@ -117,8 +117,7 @@ void KeePass2Writer::writeDatabase(QIODevice* device, Database* db)
|
||||
bool KeePass2Writer::writeData(const QByteArray& data)
|
||||
{
|
||||
if (m_device->write(data) != data.size()) {
|
||||
m_error = true;
|
||||
m_errorStr = m_device->errorString();
|
||||
raiseError(m_device->errorString());
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
@@ -143,11 +142,14 @@ bool KeePass2Writer::writeHeaderField(KeePass2::HeaderFieldID fieldId, const QBy
|
||||
void KeePass2Writer::writeDatabase(const QString& filename, Database* db)
|
||||
{
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::WriteOnly|QIODevice::Truncate);
|
||||
if (!file.open(QIODevice::WriteOnly|QIODevice::Truncate)) {
|
||||
raiseError(file.errorString());
|
||||
return;
|
||||
}
|
||||
writeDatabase(&file, db);
|
||||
}
|
||||
|
||||
bool KeePass2Writer::error()
|
||||
bool KeePass2Writer::hasError()
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
@@ -156,3 +158,9 @@ QString KeePass2Writer::errorString()
|
||||
{
|
||||
return m_errorStr;
|
||||
}
|
||||
|
||||
void KeePass2Writer::raiseError(const QString& errorMessage)
|
||||
{
|
||||
m_error = true;
|
||||
m_errorStr = errorMessage;
|
||||
}
|
||||
|
||||
@@ -30,12 +30,13 @@ public:
|
||||
KeePass2Writer();
|
||||
void writeDatabase(QIODevice* device, Database* db);
|
||||
void writeDatabase(const QString& filename, Database* db);
|
||||
bool error();
|
||||
bool hasError();
|
||||
QString errorString();
|
||||
|
||||
private:
|
||||
bool writeData(const QByteArray& data);
|
||||
bool writeHeaderField(KeePass2::HeaderFieldID fieldId, const QByteArray& data);
|
||||
void raiseError(const QString& errorMessage);
|
||||
|
||||
QIODevice* m_device;
|
||||
bool m_error;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "KeePass2XmlReader.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/DatabaseIcons.h"
|
||||
@@ -28,15 +28,21 @@
|
||||
#include "format/KeePass2RandomStream.h"
|
||||
#include "streams/QtIOCompressor"
|
||||
|
||||
typedef QPair<QString, QString> StringPair;
|
||||
|
||||
KeePass2XmlReader::KeePass2XmlReader()
|
||||
: m_randomStream(Q_NULLPTR)
|
||||
, m_db(Q_NULLPTR)
|
||||
, m_meta(Q_NULLPTR)
|
||||
, m_error(false)
|
||||
{
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2RandomStream* randomStream)
|
||||
{
|
||||
m_error = false;
|
||||
m_errorStr.clear();
|
||||
|
||||
m_xml.clear();
|
||||
m_xml.setDevice(device);
|
||||
|
||||
@@ -49,12 +55,18 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra
|
||||
|
||||
m_tmpParent = new Group();
|
||||
|
||||
bool rootGroupParsed = false;
|
||||
|
||||
if (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "KeePassFile") {
|
||||
parseKeePassFile();
|
||||
rootGroupParsed = parseKeePassFile();
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_xml.error() && !rootGroupParsed) {
|
||||
raiseError("No root group");
|
||||
}
|
||||
|
||||
if (!m_xml.error()) {
|
||||
if (!m_tmpParent->children().isEmpty()) {
|
||||
qWarning("KeePass2XmlReader::readDatabase: found %d invalid group reference(s)",
|
||||
@@ -73,7 +85,7 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra
|
||||
QSet<QString> unusedKeys = poolKeys - entryKeys;
|
||||
|
||||
if (!unmappedKeys.isEmpty()) {
|
||||
raiseError(17);
|
||||
raiseError("Unmapped keys left.");
|
||||
}
|
||||
|
||||
if (!m_xml.error()) {
|
||||
@@ -123,15 +135,29 @@ Database* KeePass2XmlReader::readDatabase(const QString& filename)
|
||||
|
||||
bool KeePass2XmlReader::hasError()
|
||||
{
|
||||
return m_xml.hasError();
|
||||
return m_error || m_xml.hasError();
|
||||
}
|
||||
|
||||
QString KeePass2XmlReader::errorString()
|
||||
{
|
||||
return QString("%1\nLine %2, column %3")
|
||||
.arg(m_xml.errorString())
|
||||
.arg(m_xml.lineNumber())
|
||||
.arg(m_xml.columnNumber());
|
||||
if (m_error) {
|
||||
return m_errorStr;
|
||||
}
|
||||
else if (m_xml.hasError()) {
|
||||
return QString("XML error:\n%1\nLine %2, column %3")
|
||||
.arg(m_xml.errorString())
|
||||
.arg(m_xml.lineNumber())
|
||||
.arg(m_xml.columnNumber());
|
||||
}
|
||||
else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::raiseError(const QString& errorMessage)
|
||||
{
|
||||
m_error = true;
|
||||
m_errorStr = errorMessage;
|
||||
}
|
||||
|
||||
QByteArray KeePass2XmlReader::headerHash()
|
||||
@@ -139,21 +165,33 @@ QByteArray KeePass2XmlReader::headerHash()
|
||||
return m_headerHash;
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseKeePassFile()
|
||||
bool KeePass2XmlReader::parseKeePassFile()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "KeePassFile");
|
||||
|
||||
bool rootElementFound = false;
|
||||
bool rootParsedSuccesfully = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Meta") {
|
||||
parseMeta();
|
||||
}
|
||||
else if (m_xml.name() == "Root") {
|
||||
parseRoot();
|
||||
if (rootElementFound) {
|
||||
rootParsedSuccesfully = false;
|
||||
raiseError("Multiple root elements");
|
||||
}
|
||||
else {
|
||||
rootParsedSuccesfully = parseRoot();
|
||||
rootElementFound = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
return rootParsedSuccesfully;
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseMeta()
|
||||
@@ -233,7 +271,7 @@ void KeePass2XmlReader::parseMeta()
|
||||
m_meta->setHistoryMaxItems(value);
|
||||
}
|
||||
else {
|
||||
raiseError(18);
|
||||
raiseError("HistoryMaxItems invalid number");
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "HistoryMaxSize") {
|
||||
@@ -242,7 +280,7 @@ void KeePass2XmlReader::parseMeta()
|
||||
m_meta->setHistoryMaxSize(value);
|
||||
}
|
||||
else {
|
||||
raiseError(19);
|
||||
raiseError("HistoryMaxSize invalid number");
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "Binaries") {
|
||||
@@ -305,19 +343,30 @@ void KeePass2XmlReader::parseIcon()
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Icon");
|
||||
|
||||
Uuid uuid;
|
||||
QImage icon;
|
||||
bool uuidSet = false;
|
||||
bool iconSet = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "UUID") {
|
||||
uuid = readUuid();
|
||||
uuidSet = true;
|
||||
}
|
||||
else if (m_xml.name() == "Data") {
|
||||
QImage icon;
|
||||
icon.loadFromData(readBinary());
|
||||
m_meta->addCustomIcon(uuid, icon);
|
||||
iconSet = true;
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (uuidSet && iconSet) {
|
||||
m_meta->addCustomIcon(uuid, icon);
|
||||
}
|
||||
else {
|
||||
raiseError("Missing icon uuid or data");
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseBinaries()
|
||||
@@ -370,31 +419,56 @@ void KeePass2XmlReader::parseCustomDataItem()
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Item");
|
||||
|
||||
QString key;
|
||||
QString value;
|
||||
bool keySet = false;
|
||||
bool valueSet = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Key") {
|
||||
key = readString();
|
||||
keySet = true;
|
||||
}
|
||||
else if (m_xml.name() == "Value") {
|
||||
m_meta->addCustomField(key, readString());
|
||||
value = readString();
|
||||
valueSet = true;
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (keySet && valueSet) {
|
||||
m_meta->addCustomField(key, value);
|
||||
}
|
||||
else {
|
||||
raiseError("Missing custom data key or value");
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseRoot()
|
||||
bool KeePass2XmlReader::parseRoot()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Root");
|
||||
|
||||
bool groupElementFound = false;
|
||||
bool groupParsedSuccesfully = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Group") {
|
||||
if (groupElementFound) {
|
||||
groupParsedSuccesfully = false;
|
||||
raiseError("Multiple group elements");
|
||||
continue;
|
||||
}
|
||||
|
||||
Group* rootGroup = parseGroup();
|
||||
if (rootGroup) {
|
||||
Group* oldRoot = m_db->rootGroup();
|
||||
m_db->setRootGroup(rootGroup);
|
||||
delete oldRoot;
|
||||
groupParsedSuccesfully = true;
|
||||
}
|
||||
|
||||
groupElementFound = true;
|
||||
}
|
||||
else if (m_xml.name() == "DeletedObjects") {
|
||||
parseDeletedObjects();
|
||||
@@ -403,21 +477,26 @@ void KeePass2XmlReader::parseRoot()
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
return groupParsedSuccesfully;
|
||||
}
|
||||
|
||||
Group* KeePass2XmlReader::parseGroup()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Group");
|
||||
|
||||
Group* group = Q_NULLPTR;
|
||||
Group* group = new Group();
|
||||
group->setUpdateTimeinfo(false);
|
||||
QList<Group*> children;
|
||||
QList<Entry*> entries;
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "UUID") {
|
||||
Uuid uuid = readUuid();
|
||||
if (uuid.isNull()) {
|
||||
raiseError(1);
|
||||
raiseError("Null group uuid");
|
||||
}
|
||||
else {
|
||||
group = getGroup(uuid);
|
||||
group->setUuid(uuid);
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "Name") {
|
||||
@@ -429,7 +508,7 @@ Group* KeePass2XmlReader::parseGroup()
|
||||
else if (m_xml.name() == "IconID") {
|
||||
int iconId = readNumber();
|
||||
if (iconId < 0) {
|
||||
raiseError(2);
|
||||
raiseError("Invalid group icon number");
|
||||
}
|
||||
else {
|
||||
if (iconId >= DatabaseIcons::IconCount) {
|
||||
@@ -466,7 +545,7 @@ Group* KeePass2XmlReader::parseGroup()
|
||||
group->setAutoTypeEnabled(Group::Disable);
|
||||
}
|
||||
else {
|
||||
raiseError(3);
|
||||
raiseError("Invalid EnableAutoType value");
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "EnableSearching") {
|
||||
@@ -482,7 +561,7 @@ Group* KeePass2XmlReader::parseGroup()
|
||||
group->setSearchingEnabled(Group::Disable);
|
||||
}
|
||||
else {
|
||||
raiseError(4);
|
||||
raiseError("Invalid EnableSearching value");
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "LastTopVisibleEntry") {
|
||||
@@ -491,13 +570,13 @@ Group* KeePass2XmlReader::parseGroup()
|
||||
else if (m_xml.name() == "Group") {
|
||||
Group* newGroup = parseGroup();
|
||||
if (newGroup) {
|
||||
newGroup->setParent(group);
|
||||
children.append(newGroup);
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "Entry") {
|
||||
Entry* newEntry = parseEntry(false);
|
||||
if (newEntry) {
|
||||
newEntry->setGroup(group);
|
||||
entries.append(newEntry);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -505,6 +584,25 @@ Group* KeePass2XmlReader::parseGroup()
|
||||
}
|
||||
}
|
||||
|
||||
if (!group->uuid().isNull()) {
|
||||
Group* tmpGroup = group;
|
||||
group = getGroup(tmpGroup->uuid());
|
||||
group->copyDataFrom(tmpGroup);
|
||||
group->setUpdateTimeinfo(false);
|
||||
delete tmpGroup;
|
||||
}
|
||||
else if (!hasError()) {
|
||||
raiseError("No group uuid found");
|
||||
}
|
||||
|
||||
Q_FOREACH (Group* child, children) {
|
||||
child->setParent(group);
|
||||
}
|
||||
|
||||
Q_FOREACH (Entry* entry, entries) {
|
||||
entry->setGroup(group);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -532,7 +630,7 @@ void KeePass2XmlReader::parseDeletedObject()
|
||||
if (m_xml.name() == "UUID") {
|
||||
Uuid uuid = readUuid();
|
||||
if (uuid.isNull()) {
|
||||
raiseError(5);
|
||||
raiseError("Null DeleteObject uuid");
|
||||
}
|
||||
else {
|
||||
delObj.uuid = uuid;
|
||||
@@ -546,35 +644,37 @@ void KeePass2XmlReader::parseDeletedObject()
|
||||
}
|
||||
}
|
||||
|
||||
m_db->addDeletedObject(delObj);
|
||||
if (!delObj.uuid.isNull() && !delObj.deletionTime.isNull()) {
|
||||
m_db->addDeletedObject(delObj);
|
||||
}
|
||||
else {
|
||||
raiseError("Missing DeletedObject uuid or time");
|
||||
}
|
||||
}
|
||||
|
||||
Entry* KeePass2XmlReader::parseEntry(bool history)
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Entry");
|
||||
|
||||
Entry* entry = 0;
|
||||
Entry* entry = new Entry();
|
||||
entry->setUpdateTimeinfo(false);
|
||||
QList<Entry*> historyItems;
|
||||
QList<StringPair> binaryRefs;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "UUID") {
|
||||
Uuid uuid = readUuid();
|
||||
if (uuid.isNull()) {
|
||||
raiseError(6);
|
||||
raiseError("Null entry uuid");
|
||||
}
|
||||
else {
|
||||
if (history) {
|
||||
entry = new Entry();
|
||||
entry->setUpdateTimeinfo(false);
|
||||
entry->setUuid(uuid);
|
||||
}
|
||||
else {
|
||||
entry = getEntry(uuid);
|
||||
}
|
||||
entry->setUuid(uuid);
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "IconID") {
|
||||
int iconId = readNumber();
|
||||
if (iconId < 0) {
|
||||
raiseError(7);
|
||||
raiseError("Invalud entry icon number");
|
||||
}
|
||||
else {
|
||||
entry->setIcon(iconId);
|
||||
@@ -605,17 +705,20 @@ Entry* KeePass2XmlReader::parseEntry(bool history)
|
||||
parseEntryString(entry);
|
||||
}
|
||||
else if (m_xml.name() == "Binary") {
|
||||
parseEntryBinary(entry);
|
||||
QPair<QString, QString> ref = parseEntryBinary(entry);
|
||||
if (!ref.first.isNull() && !ref.second.isNull()) {
|
||||
binaryRefs.append(ref);
|
||||
}
|
||||
}
|
||||
else if (m_xml.name() == "AutoType") {
|
||||
parseAutoType(entry);
|
||||
}
|
||||
else if (m_xml.name() == "History") {
|
||||
if (history) {
|
||||
raiseError(8);
|
||||
raiseError("History element in history entry");
|
||||
}
|
||||
else {
|
||||
parseEntryHistory(entry);
|
||||
historyItems = parseEntryHistory();
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -623,6 +726,32 @@ Entry* KeePass2XmlReader::parseEntry(bool history)
|
||||
}
|
||||
}
|
||||
|
||||
if (!entry->uuid().isNull()) {
|
||||
if (history) {
|
||||
entry->setUpdateTimeinfo(false);
|
||||
}
|
||||
else {
|
||||
Entry* tmpEntry = entry;
|
||||
|
||||
entry = getEntry(tmpEntry->uuid());
|
||||
entry->copyDataFrom(tmpEntry);
|
||||
entry->setUpdateTimeinfo(false);
|
||||
|
||||
delete tmpEntry;
|
||||
}
|
||||
}
|
||||
else if (!hasError()) {
|
||||
raiseError("No entry uuid found");
|
||||
}
|
||||
|
||||
Q_FOREACH (Entry* historyItem, historyItems) {
|
||||
entry->addHistoryItem(historyItem);
|
||||
}
|
||||
|
||||
Q_FOREACH (const StringPair& ref, binaryRefs) {
|
||||
m_binaryMap.insertMulti(ref.first, qMakePair(entry, ref.second));
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -631,67 +760,97 @@ void KeePass2XmlReader::parseEntryString(Entry* entry)
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "String");
|
||||
|
||||
QString key;
|
||||
QString value;
|
||||
bool protect = false;
|
||||
bool keySet = false;
|
||||
bool valueSet = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Key") {
|
||||
key = readString();
|
||||
keySet = true;
|
||||
}
|
||||
else if (m_xml.name() == "Value") {
|
||||
QXmlStreamAttributes attr = m_xml.attributes();
|
||||
QString value = readString();
|
||||
value = readString();
|
||||
|
||||
bool isProtected = attr.value("Protected") == "True";
|
||||
bool protectInMemory = attr.value("ProtectInMemory") == "True";
|
||||
|
||||
if (isProtected && !value.isEmpty()) {
|
||||
if (m_randomStream) {
|
||||
value = QString::fromUtf8(m_randomStream->process(QByteArray::fromBase64(value.toAscii())));
|
||||
value = QString::fromUtf8(m_randomStream->process(QByteArray::fromBase64(value.toLatin1())));
|
||||
}
|
||||
else {
|
||||
raiseError(9);
|
||||
raiseError("Unable to decrypt entry string");
|
||||
}
|
||||
}
|
||||
|
||||
entry->attributes()->set(key, value, isProtected || protectInMemory);
|
||||
protect = isProtected || protectInMemory;
|
||||
valueSet = true;
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (keySet && valueSet) {
|
||||
entry->attributes()->set(key, value, protect);
|
||||
}
|
||||
else {
|
||||
raiseError("Entry string key or value missing");
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseEntryBinary(Entry* entry)
|
||||
QPair<QString, QString> KeePass2XmlReader::parseEntryBinary(Entry* entry)
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Binary");
|
||||
|
||||
QPair<QString, QString> poolRef;
|
||||
|
||||
QString key;
|
||||
QByteArray value;
|
||||
bool keySet = false;
|
||||
bool valueSet = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Key") {
|
||||
key = readString();
|
||||
keySet = true;
|
||||
}
|
||||
else if (m_xml.name() == "Value") {
|
||||
QXmlStreamAttributes attr = m_xml.attributes();
|
||||
|
||||
if (attr.hasAttribute("Ref")) {
|
||||
m_binaryMap.insertMulti(attr.value("Ref").toString(), qMakePair(entry, key));
|
||||
poolRef = qMakePair(attr.value("Ref").toString(), key);
|
||||
m_xml.skipCurrentElement();
|
||||
}
|
||||
else {
|
||||
// format compatbility
|
||||
QByteArray value = readBinary();
|
||||
value = readBinary();
|
||||
bool isProtected = attr.hasAttribute("Protected")
|
||||
&& (attr.value("Protected") == "True");
|
||||
|
||||
if (isProtected && !value.isEmpty()) {
|
||||
m_randomStream->processInPlace(value);
|
||||
}
|
||||
|
||||
entry->attachments()->set(key, value);
|
||||
}
|
||||
|
||||
valueSet = true;
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (keySet && valueSet) {
|
||||
entry->attachments()->set(key, value);
|
||||
}
|
||||
else {
|
||||
raiseError("Entry binary key or value missing");
|
||||
}
|
||||
|
||||
return poolRef;
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseAutoType(Entry* entry)
|
||||
@@ -722,33 +881,47 @@ void KeePass2XmlReader::parseAutoTypeAssoc(Entry* entry)
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "Association");
|
||||
|
||||
AutoTypeAssociations::Association assoc;
|
||||
bool windowSet = false;
|
||||
bool sequenceSet = false;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Window") {
|
||||
assoc.window = readString();
|
||||
windowSet = true;
|
||||
}
|
||||
else if (m_xml.name() == "KeystrokeSequence") {
|
||||
assoc.sequence = readString();
|
||||
entry->autoTypeAssociations()->add(assoc);
|
||||
sequenceSet = true;
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
if (windowSet && sequenceSet) {
|
||||
entry->autoTypeAssociations()->add(assoc);
|
||||
}
|
||||
else {
|
||||
raiseError("Auto-type association window or sequence missing");
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::parseEntryHistory(Entry* entry)
|
||||
QList<Entry*> KeePass2XmlReader::parseEntryHistory()
|
||||
{
|
||||
Q_ASSERT(m_xml.isStartElement() && m_xml.name() == "History");
|
||||
|
||||
QList<Entry*> historyItems;
|
||||
|
||||
while (!m_xml.error() && m_xml.readNextStartElement()) {
|
||||
if (m_xml.name() == "Entry") {
|
||||
Entry* historyItem = parseEntry(true);
|
||||
entry->addHistoryItem(historyItem);
|
||||
historyItems.append(parseEntry(true));
|
||||
}
|
||||
else {
|
||||
skipCurrentElement();
|
||||
}
|
||||
}
|
||||
|
||||
return historyItems;
|
||||
}
|
||||
|
||||
TimeInfo KeePass2XmlReader::parseTimes()
|
||||
@@ -802,7 +975,7 @@ bool KeePass2XmlReader::readBool()
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
raiseError(10);
|
||||
raiseError("Invalid bool value");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -813,7 +986,7 @@ QDateTime KeePass2XmlReader::readDateTime()
|
||||
QDateTime dt = QDateTime::fromString(str, Qt::ISODate);
|
||||
|
||||
if (!dt.isValid()) {
|
||||
raiseError(11);
|
||||
raiseError("Invalid date time value");
|
||||
}
|
||||
|
||||
return dt;
|
||||
@@ -828,7 +1001,7 @@ QColor KeePass2XmlReader::readColor()
|
||||
}
|
||||
|
||||
if (colorStr.length() != 7 || colorStr[0] != '#') {
|
||||
raiseError(12);
|
||||
raiseError("Invalid color value");
|
||||
return QColor();
|
||||
}
|
||||
|
||||
@@ -838,7 +1011,7 @@ QColor KeePass2XmlReader::readColor()
|
||||
bool ok;
|
||||
int rgbPart = rgbPartStr.toInt(&ok, 16);
|
||||
if (!ok || rgbPart > 255) {
|
||||
raiseError(13);
|
||||
raiseError("Invalid color rgb part");
|
||||
return QColor();
|
||||
}
|
||||
|
||||
@@ -861,7 +1034,7 @@ int KeePass2XmlReader::readNumber()
|
||||
bool ok;
|
||||
int result = readString().toInt(&ok);
|
||||
if (!ok) {
|
||||
raiseError(14);
|
||||
raiseError("Invalid number value");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -870,7 +1043,7 @@ Uuid KeePass2XmlReader::readUuid()
|
||||
{
|
||||
QByteArray uuidBin = readBinary();
|
||||
if (uuidBin.length() != Uuid::Length) {
|
||||
raiseError(15);
|
||||
raiseError("Invalid uuid value");
|
||||
return Uuid();
|
||||
}
|
||||
else {
|
||||
@@ -880,7 +1053,7 @@ Uuid KeePass2XmlReader::readUuid()
|
||||
|
||||
QByteArray KeePass2XmlReader::readBinary()
|
||||
{
|
||||
return QByteArray::fromBase64(readString().toAscii());
|
||||
return QByteArray::fromBase64(readString().toLatin1());
|
||||
}
|
||||
|
||||
QByteArray KeePass2XmlReader::readCompressedBinary()
|
||||
@@ -896,7 +1069,7 @@ QByteArray KeePass2XmlReader::readCompressedBinary()
|
||||
|
||||
QByteArray result;
|
||||
if (!Tools::readAllFromDevice(&compressor, result)) {
|
||||
raiseError(16);
|
||||
raiseError("Unable to decompress binary");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -939,11 +1112,6 @@ Entry* KeePass2XmlReader::getEntry(const Uuid& uuid)
|
||||
}
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::raiseError(int internalNumber)
|
||||
{
|
||||
m_xml.raiseError(tr("Invalid database file (error no %1).").arg(QString::number(internalNumber)));
|
||||
}
|
||||
|
||||
void KeePass2XmlReader::skipCurrentElement()
|
||||
{
|
||||
qWarning("KeePass2XmlReader::skipCurrentElement: skip element \"%s\"", qPrintable(m_xml.name().toString()));
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
#ifndef KEEPASSX_KEEPASS2XMLREADER_H
|
||||
#define KEEPASSX_KEEPASS2XMLREADER_H
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QPair>
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
#include <QtGui/QColor>
|
||||
#include <QColor>
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QPair>
|
||||
#include <QXmlStreamReader>
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "core/TimeInfo.h"
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
QByteArray headerHash();
|
||||
|
||||
private:
|
||||
void parseKeePassFile();
|
||||
bool parseKeePassFile();
|
||||
void parseMeta();
|
||||
void parseMemoryProtection();
|
||||
void parseCustomIcons();
|
||||
@@ -57,16 +57,16 @@ private:
|
||||
void parseBinaries();
|
||||
void parseCustomData();
|
||||
void parseCustomDataItem();
|
||||
void parseRoot();
|
||||
bool parseRoot();
|
||||
Group* parseGroup();
|
||||
void parseDeletedObjects();
|
||||
void parseDeletedObject();
|
||||
Entry* parseEntry(bool history);
|
||||
void parseEntryString(Entry* entry);
|
||||
void parseEntryBinary(Entry* entry);
|
||||
QPair<QString, QString> parseEntryBinary(Entry* entry);
|
||||
void parseAutoType(Entry* entry);
|
||||
void parseAutoTypeAssoc(Entry* entry);
|
||||
void parseEntryHistory(Entry* entry);
|
||||
QList<Entry*> parseEntryHistory();
|
||||
TimeInfo parseTimes();
|
||||
|
||||
QString readString();
|
||||
@@ -80,7 +80,7 @@ private:
|
||||
|
||||
Group* getGroup(const Uuid& uuid);
|
||||
Entry* getEntry(const Uuid& uuid);
|
||||
void raiseError(int internalNumber);
|
||||
void raiseError(const QString& errorMessage);
|
||||
void skipCurrentElement();
|
||||
|
||||
QXmlStreamReader m_xml;
|
||||
@@ -93,6 +93,8 @@ private:
|
||||
QHash<QString, QByteArray> m_binaryPool;
|
||||
QHash<QString, QPair<Entry*, QString> > m_binaryMap;
|
||||
QByteArray m_headerHash;
|
||||
bool m_error;
|
||||
QString m_errorStr;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_KEEPASS2XMLREADER_H
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "KeePass2XmlWriter.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFile>
|
||||
#include <QBuffer>
|
||||
#include <QFile>
|
||||
|
||||
#include "core/Metadata.h"
|
||||
#include "format/KeePass2RandomStream.h"
|
||||
@@ -192,7 +192,7 @@ void KeePass2XmlWriter::writeBinaries()
|
||||
}
|
||||
|
||||
if (!data.isEmpty()) {
|
||||
m_xml.writeCharacters(QString::fromAscii(data.toBase64()));
|
||||
m_xml.writeCharacters(QString::fromLatin1(data.toBase64()));
|
||||
}
|
||||
m_xml.writeEndElement();
|
||||
}
|
||||
@@ -341,7 +341,7 @@ void KeePass2XmlWriter::writeEntry(const Entry* entry)
|
||||
if (m_randomStream) {
|
||||
m_xml.writeAttribute("Protected", "True");
|
||||
QByteArray rawData = m_randomStream->process(entry->attributes()->value(key).toUtf8());
|
||||
value = QString::fromAscii(rawData.toBase64());
|
||||
value = QString::fromLatin1(rawData.toBase64());
|
||||
}
|
||||
else {
|
||||
m_xml.writeAttribute("ProtectInMemory", "True");
|
||||
@@ -485,7 +485,7 @@ void KeePass2XmlWriter::writeUuid(const QString& qualifiedName, const Entry* ent
|
||||
|
||||
void KeePass2XmlWriter::writeBinary(const QString& qualifiedName, const QByteArray& ba)
|
||||
{
|
||||
writeString(qualifiedName, QString::fromAscii(ba.toBase64()));
|
||||
writeString(qualifiedName, QString::fromLatin1(ba.toBase64()));
|
||||
}
|
||||
|
||||
void KeePass2XmlWriter::writeColor(const QString& qualifiedName, const QColor& color)
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#ifndef KEEPASSX_KEEPASS2XMLWRITER_H
|
||||
#define KEEPASSX_KEEPASS2XMLWRITER_H
|
||||
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QXmlStreamWriter>
|
||||
#include <QtGui/QColor>
|
||||
#include <QtGui/QImage>
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QImage>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_ABOUTDIALOG_H
|
||||
#define KEEPASSX_ABOUTDIALOG_H
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include <QtGui/QFileOpenEvent>
|
||||
#include <QFileOpenEvent>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef KEEPASSX_APPLICATION_H
|
||||
#define KEEPASSX_APPLICATION_H
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QApplication>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
#include "ChangeMasterKeyWidget.h"
|
||||
#include "ui_ChangeMasterKeyWidget.h"
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
#include "keys/FileKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
|
||||
ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
||||
: DialogyWidget(parent)
|
||||
@@ -56,7 +55,7 @@ void ChangeMasterKeyWidget::createKeyFile()
|
||||
QString errorMsg;
|
||||
bool created = FileKey::create(fileName, &errorMsg);
|
||||
if (!created) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("Unable to create Key File : ") + errorMsg);
|
||||
MessageBox::warning(this, tr("Error"), tr("Unable to create Key File : ") + errorMsg);
|
||||
}
|
||||
else {
|
||||
m_ui->keyFileCombo->setEditText(fileName);
|
||||
@@ -105,16 +104,16 @@ void ChangeMasterKeyWidget::generateKey()
|
||||
if (m_ui->passwordGroup->isChecked()) {
|
||||
if (m_ui->enterPasswordEdit->text() == m_ui->repeatPasswordEdit->text()) {
|
||||
if (m_ui->enterPasswordEdit->text().isEmpty()) {
|
||||
if (QMessageBox::question(this, tr("Question"),
|
||||
tr("Do you really want to use an empty string as password?"),
|
||||
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
|
||||
if (MessageBox::question(this, tr("Question"),
|
||||
tr("Do you really want to use an empty string as password?"),
|
||||
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_key.addKey(PasswordKey(m_ui->enterPasswordEdit->text()));
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(this, tr("Error"), tr("Different passwords supplied."));
|
||||
MessageBox::warning(this, tr("Error"), tr("Different passwords supplied."));
|
||||
m_ui->enterPasswordEdit->setText("");
|
||||
m_ui->repeatPasswordEdit->setText("");
|
||||
return;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_CHANGEMASTERKEYWIDGET_H
|
||||
#define KEEPASSX_CHANGEMASTERKEYWIDGET_H
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "gui/DialogyWidget.h"
|
||||
#include "keys/CompositeKey.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>438</width>
|
||||
<height>242</height>
|
||||
<height>249</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -154,8 +154,8 @@
|
||||
<tabstops>
|
||||
<tabstop>passwordGroup</tabstop>
|
||||
<tabstop>enterPasswordEdit</tabstop>
|
||||
<tabstop>repeatPasswordEdit</tabstop>
|
||||
<tabstop>togglePasswordButton</tabstop>
|
||||
<tabstop>repeatPasswordEdit</tabstop>
|
||||
<tabstop>keyFileGroup</tabstop>
|
||||
<tabstop>keyFileCombo</tabstop>
|
||||
<tabstop>browseKeyFileButton</tabstop>
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
|
||||
#include "Clipboard.h"
|
||||
|
||||
#include <QtCore/QTimer>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QClipboard>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QTimer>
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#endif
|
||||
|
||||
#include "core/Config.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_CLIPBOARD_H
|
||||
#define KEEPASSX_CLIPBOARD_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QObject>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
|
||||
@@ -18,11 +18,10 @@
|
||||
#include "DatabaseOpenWidget.h"
|
||||
#include "ui_DatabaseOpenWidget.h"
|
||||
|
||||
#include <QtGui/QMessageBox>
|
||||
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "format/KeePass2Reader.h"
|
||||
#include "keys/FileKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
@@ -115,8 +114,8 @@ void DatabaseOpenWidget::openDatabase()
|
||||
Q_EMIT editFinished(true);
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(this, tr("Error"), tr("Unable to open the database.\n%1")
|
||||
.arg(reader.errorString()));
|
||||
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.\n%1")
|
||||
.arg(reader.errorString()));
|
||||
m_ui->editPassword->clear();
|
||||
}
|
||||
}
|
||||
@@ -136,7 +135,7 @@ CompositeKey DatabaseOpenWidget::databaseKey()
|
||||
QString keyFilename = m_ui->comboKeyFile->currentText();
|
||||
QString errorMsg;
|
||||
if (!key.load(keyFilename, &errorMsg)) {
|
||||
QMessageBox::warning(this, tr("Error"), tr("Can't open key file:\n%1").arg(errorMsg));
|
||||
MessageBox::warning(this, tr("Error"), tr("Can't open key file:\n%1").arg(errorMsg));
|
||||
return CompositeKey();
|
||||
}
|
||||
masterKey.addKey(key);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_DATABASEOPENWIDGET_H
|
||||
#define KEEPASSX_DATABASEOPENWIDGET_H
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "gui/DialogyWidget.h"
|
||||
#include "keys/CompositeKey.h"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef KEEPASSX_DATABASESETTINGSWIDGET_H
|
||||
#define KEEPASSX_DATABASESETTINGSWIDGET_H
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "gui/DialogyWidget.h"
|
||||
|
||||
|
||||
@@ -188,8 +188,14 @@
|
||||
<tabstops>
|
||||
<tabstop>dbNameEdit</tabstop>
|
||||
<tabstop>dbDescriptionEdit</tabstop>
|
||||
<tabstop>transformRoundsSpinBox</tabstop>
|
||||
<tabstop>transformBenchmarkButton</tabstop>
|
||||
<tabstop>defaultUsernameEdit</tabstop>
|
||||
<tabstop>recycleBinEnabledCheckBox</tabstop>
|
||||
<tabstop>historyMaxItemsCheckBox</tabstop>
|
||||
<tabstop>historyMaxItemsSpinBox</tabstop>
|
||||
<tabstop>historyMaxSizeCheckBox</tabstop>
|
||||
<tabstop>historyMaxSizeSpinBox</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
|
||||
@@ -17,9 +17,8 @@
|
||||
|
||||
#include "DatabaseTabWidget.h"
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include "autotype/AutoType.h"
|
||||
#include "core/Config.h"
|
||||
@@ -30,6 +29,7 @@
|
||||
#include "gui/DatabaseWidget.h"
|
||||
#include "gui/DragTabBar.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
#include "gui/entry/EntryView.h"
|
||||
#include "gui/group/GroupView.h"
|
||||
|
||||
@@ -106,7 +106,7 @@ void DatabaseTabWidget::openDatabase(const QString& fileName, const QString& pw,
|
||||
QFileInfo fileInfo(fileName);
|
||||
QString canonicalFilePath = fileInfo.canonicalFilePath();
|
||||
if (canonicalFilePath.isEmpty()) {
|
||||
QMessageBox::warning(this, tr("Warning"), tr("File not found!"));
|
||||
MessageBox::warning(this, tr("Warning"), tr("File not found!"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
}
|
||||
if (dbStruct.dbWidget->currentMode() == DatabaseWidget::EditMode && db->hasKey()) {
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(
|
||||
MessageBox::question(
|
||||
this, tr("Close?"),
|
||||
tr("\"%1\" is in edit mode.\nClose anyway?").arg(dbName),
|
||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
@@ -205,7 +205,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
}
|
||||
else {
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(
|
||||
MessageBox::question(
|
||||
this, tr("Save changes?"),
|
||||
tr("\"%1\" was modified.\nSave changes?").arg(dbName),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
|
||||
@@ -226,6 +226,9 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
void DatabaseTabWidget::deleteDatabase(Database* db)
|
||||
{
|
||||
const DatabaseManagerStruct dbStruct = m_dbList.value(db);
|
||||
bool emitDatabaseWithFileClosed = dbStruct.saveToFilename;
|
||||
QString filePath = dbStruct.filePath;
|
||||
|
||||
int index = databaseIndex(db);
|
||||
|
||||
removeTab(index);
|
||||
@@ -233,6 +236,10 @@ void DatabaseTabWidget::deleteDatabase(Database* db)
|
||||
m_dbList.remove(db);
|
||||
delete dbStruct.dbWidget;
|
||||
delete db;
|
||||
|
||||
if (emitDatabaseWithFileClosed) {
|
||||
Q_EMIT databaseWithFileClosed(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
bool DatabaseTabWidget::closeAllDatabases()
|
||||
@@ -263,8 +270,8 @@ void DatabaseTabWidget::saveDatabase(Database* db)
|
||||
updateTabName(db);
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -302,8 +309,8 @@ void DatabaseTabWidget::saveDatabaseAs(Database* db)
|
||||
updateLastDatabases(dbStruct.filePath);
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
MessageBox::critical(this, tr("Error"), tr("Writing the database failed.") + "\n\n"
|
||||
+ saveFile.errorString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
#ifndef KEEPASSX_DATABASETABWIDGET_H
|
||||
#define KEEPASSX_DATABASETABWIDGET_H
|
||||
|
||||
#include <QtCore/QHash>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QHash>
|
||||
#include <QTabWidget>
|
||||
|
||||
#include "format/KeePass2Writer.h"
|
||||
#include "gui/DatabaseWidget.h"
|
||||
@@ -74,6 +74,7 @@ public Q_SLOTS:
|
||||
|
||||
Q_SIGNALS:
|
||||
void tabNameChanged();
|
||||
void databaseWithFileClosed(QString filePath);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTabName(Database* db);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user