Compare commits
332 Commits
2.0-alpha5
...
2.0.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8857ac2ba | ||
|
|
367fbbba39 | ||
|
|
abf469f743 | ||
|
|
878995366a | ||
|
|
1635a5211f | ||
|
|
595b1011dd | ||
|
|
9bb291235d | ||
|
|
7d4ef0b8d0 | ||
|
|
8d16522d39 | ||
|
|
cd1192b409 | ||
|
|
bf2fd63131 | ||
|
|
9532bedd7d | ||
|
|
e9c8363b70 | ||
|
|
fb57ed2bcd | ||
|
|
57ec558396 | ||
|
|
6e2de1cd79 | ||
|
|
8ace3ab7f2 | ||
|
|
18e4dca6c9 | ||
|
|
48eca3e11f | ||
|
|
57c1a0f4b6 | ||
|
|
bde4d63fdb | ||
|
|
4867d26f7d | ||
|
|
9bd3ab717e | ||
|
|
3679b21701 | ||
|
|
49f58b4ed8 | ||
|
|
235361faf4 | ||
|
|
208b803fbe | ||
|
|
8a92cec03f | ||
|
|
00f068b93e | ||
|
|
654353e26b | ||
|
|
d670ef2638 | ||
|
|
aff935b3c7 | ||
|
|
107c0673c7 | ||
|
|
c14d04b3e8 | ||
|
|
7a017041bf | ||
|
|
eb56bd8973 | ||
|
|
93585aded7 | ||
|
|
38245aa2a9 | ||
|
|
1f33e6f044 | ||
|
|
4752adf9d3 | ||
|
|
2d741afe3e | ||
|
|
5e6b17aba4 | ||
|
|
c51098e2cf | ||
|
|
24275d8dc4 | ||
|
|
94d82948f6 | ||
|
|
54fb1abb96 | ||
|
|
a3b936fcd0 | ||
|
|
efc4cd5969 | ||
|
|
17ab438c5a | ||
|
|
77b4bfb14e | ||
|
|
7839280cb3 | ||
|
|
9e1ea264e2 | ||
|
|
b02ec98ec6 | ||
|
|
2fa531745f | ||
|
|
820941fd40 | ||
|
|
862941abf6 | ||
|
|
e98c30f633 | ||
|
|
316a7e6fb7 | ||
|
|
58ed99d562 | ||
|
|
840642394f | ||
|
|
ebeedba072 | ||
|
|
568dfde074 | ||
|
|
b8c1829857 | ||
|
|
4f2d56a55f | ||
|
|
6b49f8f26b | ||
|
|
fc8cb7cd14 | ||
|
|
727094abc6 | ||
|
|
bcb54bc38a | ||
|
|
14aac09318 | ||
|
|
9d42db9849 | ||
|
|
ee81c7c00e | ||
|
|
2edf414aa4 | ||
|
|
54f44f5267 | ||
|
|
6ab54bc95a | ||
|
|
673dff2268 | ||
|
|
bb38be40f6 | ||
|
|
f236c32063 | ||
|
|
236edae60b | ||
|
|
a954e9a4d8 | ||
|
|
95c449481e | ||
|
|
0b43607aa1 | ||
|
|
e75efb8bfb | ||
|
|
d83fee89bd | ||
|
|
b773dbe645 | ||
|
|
5c7c7f54fa | ||
|
|
98417d6465 | ||
|
|
0ea64afe92 | ||
|
|
a862f62fe8 | ||
|
|
5bd525a6dd | ||
|
|
af3d896bdf | ||
|
|
ceeb72a277 | ||
|
|
2c17fdcff0 | ||
|
|
41a7c96968 | ||
|
|
98d9dae087 | ||
|
|
2033174d95 | ||
|
|
606e36acf3 | ||
|
|
0422943d52 | ||
|
|
0024f2e30f | ||
|
|
abe5e8ecea | ||
|
|
61503a8047 | ||
|
|
fcb5deff0a | ||
|
|
fdec16c3a0 | ||
|
|
84ee8b993f | ||
|
|
3d1c27ceb7 | ||
|
|
7d3fb58cf5 | ||
|
|
df5da2fcef | ||
|
|
1226d1dbd5 | ||
|
|
607007f94f | ||
|
|
6327eaf587 | ||
|
|
b1fd99f4c4 | ||
|
|
d1331053c8 | ||
|
|
c6fe0da569 | ||
|
|
b9fe2c1bf9 | ||
|
|
3efc8f457a | ||
|
|
65e8732eeb | ||
|
|
e82015d419 | ||
|
|
fa0fe6d33d | ||
|
|
8be135adf9 | ||
|
|
d04927ce7f | ||
|
|
6889cc2f20 | ||
|
|
8325b20d36 | ||
|
|
826cd472c8 | ||
|
|
8ecab15c33 | ||
|
|
c9520214e2 | ||
|
|
6d1ca363af | ||
|
|
2170794d9c | ||
|
|
719ac64851 | ||
|
|
d3a7e0dee9 | ||
|
|
240919335f | ||
|
|
ceb6a0383e | ||
|
|
0185b112e1 | ||
|
|
af84261eb6 | ||
|
|
274f86fd04 | ||
|
|
bcc3108c3d | ||
|
|
5f1b286630 | ||
|
|
8ad48d6774 | ||
|
|
721bec9794 | ||
|
|
c6105a08ab | ||
|
|
154f1673e9 | ||
|
|
577609b3e3 | ||
|
|
f22069bb11 | ||
|
|
280a1aceb9 | ||
|
|
bcd3de1180 | ||
|
|
f4361dd4d5 | ||
|
|
fc43aa1717 | ||
|
|
d553698b20 | ||
|
|
7db9c78855 | ||
|
|
7a2c02f0df | ||
|
|
c535736853 | ||
|
|
a8bf6a9782 | ||
|
|
0458dad6dc | ||
|
|
68373730bf | ||
|
|
5d9039ea89 | ||
|
|
7e1faadd11 | ||
|
|
fceb93061d | ||
|
|
c9d007fcdf | ||
|
|
eeb940c0dc | ||
|
|
05b5446e94 | ||
|
|
b45437d502 | ||
|
|
a599787a25 | ||
|
|
58061af959 | ||
|
|
8bf1bb0517 | ||
|
|
d26cff520f | ||
|
|
04aa10cee7 | ||
|
|
ade684d501 | ||
|
|
4362c3ea38 | ||
|
|
e0d4b4b625 | ||
|
|
cfffdae573 | ||
|
|
f6243675c9 | ||
|
|
a762cef0a9 | ||
|
|
a7f4e2d0cd | ||
|
|
ae013c2196 | ||
|
|
eefe844dcd | ||
|
|
94111c3662 | ||
|
|
3fca61dc24 | ||
|
|
e41bf008e9 | ||
|
|
6c9c0fd5c5 | ||
|
|
f3d956ceed | ||
|
|
b9c9c56059 | ||
|
|
bed58cde84 | ||
|
|
855d79e28f | ||
|
|
a044467d10 | ||
|
|
ecb2e337ef | ||
|
|
2dde18b179 | ||
|
|
6411b9bd66 | ||
|
|
cf0bc32b27 | ||
|
|
93ab7eb058 | ||
|
|
bd3ae05fcf | ||
|
|
b055d524e8 | ||
|
|
9e051e835b | ||
|
|
3ab1072e9e | ||
|
|
00df73ced0 | ||
|
|
940a5026c1 | ||
|
|
2631277184 | ||
|
|
b86b640860 | ||
|
|
2dfc740782 | ||
|
|
e4985f4ff7 | ||
|
|
22f579a59e | ||
|
|
c9d12e93c2 | ||
|
|
778f01bcf1 | ||
|
|
ccb7a4c96d | ||
|
|
33650c4a04 | ||
|
|
019cf9684c | ||
|
|
835c411d12 | ||
|
|
e4758c1984 | ||
|
|
eb22f0a2d8 | ||
|
|
3ea0592b53 | ||
|
|
876a75b572 | ||
|
|
c39898dad9 | ||
|
|
07a3d7a696 | ||
|
|
7f412fbd7f | ||
|
|
2adc64939f | ||
|
|
71d39865b3 | ||
|
|
226c061c01 | ||
|
|
dd2fbebb81 | ||
|
|
889c742a33 | ||
|
|
5cc3334325 | ||
|
|
e58be44523 | ||
|
|
34a7321786 | ||
|
|
07e4fbacd4 | ||
|
|
8fd69e084e | ||
|
|
dd79105baa | ||
|
|
b1c3814972 | ||
|
|
57107ea560 | ||
|
|
4b3a82592c | ||
|
|
6ecb8690f2 | ||
|
|
1c365b8417 | ||
|
|
315df0b8a8 | ||
|
|
87468b648b | ||
|
|
4cdb9a645d | ||
|
|
870d7355ca | ||
|
|
f1aa6aca26 | ||
|
|
72b59d541a | ||
|
|
0e8aa0bc6c | ||
|
|
3a0648cf25 | ||
|
|
2e76385cae | ||
|
|
867d14f7aa | ||
|
|
0d6117bf4c | ||
|
|
b417bf9187 | ||
|
|
7137990a21 | ||
|
|
916ab99d62 | ||
|
|
5a31e055cf | ||
|
|
28694ae687 | ||
|
|
becd3a0019 | ||
|
|
8cc1e6008e | ||
|
|
910788c038 | ||
|
|
9391de74c7 | ||
|
|
c806f9ebf4 | ||
|
|
e776de8eeb | ||
|
|
a25b28ffee | ||
|
|
0e75e6ff03 | ||
|
|
76da4a6cd4 | ||
|
|
8a4100adbd | ||
|
|
584f4b50bf | ||
|
|
9ac01c930d | ||
|
|
d874f58a39 | ||
|
|
05de45dadb | ||
|
|
4ab887c773 | ||
|
|
552ca7bf71 | ||
|
|
2d8ba2b394 | ||
|
|
a6d44034a4 | ||
|
|
77af79498c | ||
|
|
ea3375490c | ||
|
|
204cd8d971 | ||
|
|
c2940a8f18 | ||
|
|
4f60df029d | ||
|
|
819cfd459a | ||
|
|
c90ac914bb | ||
|
|
8bf4826003 | ||
|
|
e361b0dd81 | ||
|
|
ce7e01a1b1 | ||
|
|
cda5e990ac | ||
|
|
50cbd80925 | ||
|
|
75d3e6261b | ||
|
|
bf39d0b1be | ||
|
|
147cd4ed7b | ||
|
|
9363d23e09 | ||
|
|
b718e9d8f2 | ||
|
|
d6c30b0886 | ||
|
|
7c7f0b93ae | ||
|
|
e263c475c9 | ||
|
|
c917096d3c | ||
|
|
5de62a5ef4 | ||
|
|
7893a2e84d | ||
|
|
ad26d962dc | ||
|
|
967a9f0195 | ||
|
|
6c663a19bf | ||
|
|
b194c29166 | ||
|
|
0b9167c78b | ||
|
|
63ae460a80 | ||
|
|
43a1d54bba | ||
|
|
2963752585 | ||
|
|
1decdc6c11 | ||
|
|
6659745e2b | ||
|
|
1e2d1a1b17 | ||
|
|
f300ca5b7b | ||
|
|
b9370c6e79 | ||
|
|
54bb7462f6 | ||
|
|
4a08101a60 | ||
|
|
809be5f89e | ||
|
|
bf9a755bea | ||
|
|
34b82da9aa | ||
|
|
e0c59395da | ||
|
|
b07de47e35 | ||
|
|
586de64293 | ||
|
|
9321943e64 | ||
|
|
c00550078c | ||
|
|
2190260a68 | ||
|
|
678c4a8ece | ||
|
|
c2781274a0 | ||
|
|
bc14898b13 | ||
|
|
b6497d9245 | ||
|
|
79d827ffa4 | ||
|
|
811eb2714f | ||
|
|
a914b837a1 | ||
|
|
04c9332a99 | ||
|
|
97f374a189 | ||
|
|
6f3648d63e | ||
|
|
350cf4b00a | ||
|
|
3af2307468 | ||
|
|
29c997e1bc | ||
|
|
223c5a1651 | ||
|
|
8b437821a2 | ||
|
|
4ded95a060 | ||
|
|
0b6b149351 | ||
|
|
eee909e948 | ||
|
|
8c7e655274 | ||
|
|
8e86437e89 | ||
|
|
a8edad1e27 | ||
|
|
41162ea2e8 | ||
|
|
0f91e0d141 | ||
|
|
6a50a76466 |
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
src/version.h.cmake export-subst
|
||||
21
.travis.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
language: cpp
|
||||
install:
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq update; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -qq install cmake libqt4-dev libgcrypt11-dev zlib1g-dev libxtst-dev; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew update; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew ls | grep -wq cmake || brew install cmake; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew ls | grep -wq qt || brew install qt; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew ls | grep -wq libgcrypt || brew install libgcrypt; fi
|
||||
before_script: mkdir build && pushd build
|
||||
script:
|
||||
- cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_GUI_TESTS=ON ..
|
||||
- make
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then make test ARGS+="-E testgui --output-on-failure"; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then xvfb-run -a --server-args="-screen 0 800x600x24" make test ARGS+="-R testgui --output-on-failure"; fi
|
||||
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then make test ARGS+="--output-on-failure"; fi
|
||||
8
.tx/config
Normal file
@@ -0,0 +1,8 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
|
||||
[keepassx.keepassx_ents]
|
||||
source_file = share/translations/keepassx_en.ts
|
||||
file_filter = share/translations/keepassx_<lang>.ts
|
||||
source_lang = en
|
||||
type = QT
|
||||
79
CHANGELOG
@@ -1,3 +1,81 @@
|
||||
2.0.3 (2016-09-04)
|
||||
=========================
|
||||
|
||||
- Improved error reporting when reading / writing databases fails. [#450, #462]
|
||||
- Display an error message when opening a custom icon fails.
|
||||
- Detect custom icon format based on contents instead of the filename. [#512]
|
||||
- Keep symlink intact when saving databases. [#442].
|
||||
- Fix a crash when deleting parent group of recycle bin. [#520]
|
||||
- Display a confirm dialog before moving an entry to the recycle bin. [#447]
|
||||
- Repair UUIDs of inconsistent history items. [#130]
|
||||
- Only include top-level windows in auto-type window list when using gnome-shell.
|
||||
- Update translations.
|
||||
|
||||
2.0.2 (2016-02-02)
|
||||
=========================
|
||||
|
||||
- Fix regression in database writer that caused it to strip certain special
|
||||
characters (characters from Unicode plane > 0).
|
||||
- Fix bug in repair function that caused it to strip non-ASCII characters.
|
||||
|
||||
2.0.1 (2016-01-31)
|
||||
=========================
|
||||
|
||||
- Flush temporary file before opening attachment. [#390]
|
||||
- Disable password generator when showing entry in history mode. [#422]
|
||||
- Strip invalid XML chars when writing databases. [#392]
|
||||
- Add repair function to fix databases with invalid XML chars. [#392]
|
||||
- Display custom icons scaled. [#322]
|
||||
- Allow opening databases that have no password and keyfile. [#391]
|
||||
- Fix crash when importing .kdb files with invalid icon ids. [#425]
|
||||
- Update translations.
|
||||
|
||||
2.0 (2015-12-06)
|
||||
=========================
|
||||
|
||||
- Improve UI of the search edit.
|
||||
- Clear clipboard when locking databases. [#342]
|
||||
- Enable Ctrl+M shortcut to minimize the window on all platforms. [#329]
|
||||
- Show a better message when trying to open an old database format. [#338]
|
||||
- Fix global auto-type behavior with some window managers.
|
||||
- Show global auto-type window on the active desktop. [#359]
|
||||
- Disable systray on OS X. [#326]
|
||||
- Restore main window when clicking on the OS X docker icon. [#326]
|
||||
|
||||
2.0 Beta 2 (2015-09-06)
|
||||
=========================
|
||||
|
||||
- Fix crash when locking with search UI open [#309]
|
||||
- Fix file locking on Mac OS X [#327]
|
||||
- Set default extension when saving a database [#79, #308]
|
||||
|
||||
2.0 Beta 1 (2015-07-18)
|
||||
=========================
|
||||
|
||||
- Remember entry column sizes [#159]
|
||||
- Add translations
|
||||
- Support opening attachments directly
|
||||
- Support cmd:// URLs [#244]
|
||||
- Protect opened databases with a file lock [#18]
|
||||
- Export to csv files [#57]
|
||||
- Add optional tray icon [#153]
|
||||
- Allow setting the default auto-type sequence for groups [#175]
|
||||
- Make the kdbx parser more lenient
|
||||
- Remove --password command line option [#285]
|
||||
|
||||
2.0 Alpha 6 (2014-04-12)
|
||||
=========================
|
||||
|
||||
- Add option to lock databases after user inactivity [#62]
|
||||
- Add compatibility with libgcrypt 1.6 [#129]
|
||||
- Display passwords in monospace font [#51]
|
||||
- Use an icon for the button that shows/masks passwords [#38]
|
||||
- Add an option to show passwords by default [#93]
|
||||
- Improve password generator design [#122]
|
||||
- On Linux link .kdbx files with KeePassX
|
||||
- Remember window size [#154]
|
||||
- Disallow global auto-typing when the database is locked
|
||||
|
||||
2.0 Alpha 5 (2013-12-20)
|
||||
=========================
|
||||
|
||||
@@ -42,7 +120,6 @@
|
||||
- Sortable entry view
|
||||
- Support building Mac OS X bundles
|
||||
|
||||
|
||||
2.0 Alpha 1 (2012-05-07)
|
||||
=========================
|
||||
|
||||
|
||||
@@ -31,11 +31,10 @@ include(CheckCXXSourceCompiles)
|
||||
|
||||
option(WITH_TESTS "Enable building of unit tests" ON)
|
||||
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)
|
||||
option(WITH_CXX11 "Build with the C++ 11 standard" ON)
|
||||
|
||||
set(KEEPASSX_VERSION "2.0 alpha 5")
|
||||
set(KEEPASSX_VERSION_NUM "1.9.84")
|
||||
set(KEEPASSX_VERSION "2.0.3")
|
||||
set(KEEPASSX_VERSION_NUM "2.0.3")
|
||||
|
||||
if("${CMAKE_C_COMPILER}" MATCHES "clang$" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_CLANG 1)
|
||||
@@ -101,23 +100,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,relro")
|
||||
endif()
|
||||
|
||||
if(WITH_LTO)
|
||||
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
|
||||
check_cxx_compiler_flag("-flto -fuse-linker-plugin" LTO_AVAILABLE)
|
||||
|
||||
if(LTO_AVAILABLE)
|
||||
add_gcc_compiler_flags("-flto -fuse-linker-plugin")
|
||||
else()
|
||||
message(FATAL_ERROR "This version of gcc doesn't support LTO")
|
||||
endif(LTO_AVAILABLE)
|
||||
else()
|
||||
message(FATAL_ERROR "LTO is only supported with gcc")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WITH_CXX11)
|
||||
add_gcc_compiler_cxxflags("-std=c++0x")
|
||||
add_gcc_compiler_cflags("-ansi")
|
||||
if(APPLE)
|
||||
add_gcc_compiler_cxxflags("-stdlib=libc++")
|
||||
endif()
|
||||
else()
|
||||
add_gcc_compiler_flags("-ansi")
|
||||
endif()
|
||||
@@ -151,7 +139,7 @@ else()
|
||||
|
||||
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
|
||||
set(PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/keepassx")
|
||||
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/keepassx")
|
||||
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/keepassx")
|
||||
endif()
|
||||
|
||||
if(WITH_TESTS)
|
||||
@@ -159,14 +147,18 @@ if(WITH_TESTS)
|
||||
endif(WITH_TESTS)
|
||||
|
||||
set(QT_REQUIRED_MODULES QtCore QtGui QtTest)
|
||||
if(UNIX AND NOT APPLE)
|
||||
set(QT_REQUIRED_MODULES ${QT_REQUIRED_MODULES} QtDBus)
|
||||
endif()
|
||||
|
||||
find_package(Qt4 4.6.0 REQUIRED ${QT_REQUIRED_MODULES})
|
||||
include(${QT_USE_FILE})
|
||||
# Debian sets the the build type to None for package builds.
|
||||
# Make sure we don't enable asserts there.
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_NONE QT_NO_DEBUG)
|
||||
|
||||
find_package(Gcrypt REQUIRED)
|
||||
if(NOT (${GCRYPT_VERSION_STRING} VERSION_LESS "1.6.0"))
|
||||
message(STATUS "Gcrypt ${GCRYPT_VERSION_STRING} supports the SALSA20 cipher")
|
||||
set(GCRYPT_HAS_SALSA20 1)
|
||||
endif()
|
||||
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
|
||||
9
COPYING
@@ -25,6 +25,8 @@ Copyright: 2010-2012, Felix Geyer <debfx@fobos.de>
|
||||
2012, Intel Corporation
|
||||
2012, Nokia Corporation and/or its subsidiary(-ies)
|
||||
2000-2008, Tom Sato <VEF00200@nifty.ne.jp>
|
||||
2013, Laszlo Papp <lpapp@kde.org>
|
||||
2013, David Faure <faure@kde.org>
|
||||
License: GPL-2 or GPL-3
|
||||
|
||||
Files: cmake/GNUInstallDirs.cmake
|
||||
@@ -134,7 +136,10 @@ Files: share/icons/application/*/actions/application-exit.png
|
||||
share/icons/application/*/actions/document-save-as.png
|
||||
share/icons/application/*/actions/edit-clear-locationbar-ltr.png
|
||||
share/icons/application/*/actions/edit-clear-locationbar-rtl.png
|
||||
share/icons/application/*/actions/password-copy.png
|
||||
share/icons/application/*/actions/password-show-*.png
|
||||
share/icons/application/*/actions/system-search.png
|
||||
share/icons/application/*/actions/username-copy.png
|
||||
share/icons/application/*/status/dialog-error.png
|
||||
share/icons/application/*/status/dialog-information.png
|
||||
share/icons/application/*/status/dialog-warning.png
|
||||
@@ -178,3 +183,7 @@ Files: src/streams/qtiocompressor.*
|
||||
tests/modeltest.*
|
||||
Copyright: 2009-2012, Nokia Corporation and/or its subsidiary(-ies)
|
||||
License: LGPL-2.1 or GPL-3
|
||||
|
||||
Files: cmake/GetGitRevisionDescription.cmake*
|
||||
Copyright: 2009-2010, Iowa State University
|
||||
License: Boost-1.0
|
||||
|
||||
2
INSTALL
@@ -2,7 +2,7 @@ Building:
|
||||
=========
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. [CMAKE PARAMETERS]
|
||||
cmake [CMAKE PARAMETERS] ..
|
||||
make [-jX]
|
||||
|
||||
Common cmake parameters:
|
||||
|
||||
23
LICENSE.BOOST-1.0
Normal file
@@ -0,0 +1,23 @@
|
||||
Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
Permission is hereby granted, free of charge, to any person or organization
|
||||
obtaining a copy of the software and accompanying documentation covered by
|
||||
this license (the "Software") to use, reproduce, display, distribute,
|
||||
execute, and transmit the Software, and to prepare derivative works of the
|
||||
Software, and to permit third-parties to whom the Software is furnished to
|
||||
do so, all subject to the following:
|
||||
|
||||
The copyright notices in the Software and this entire statement, including
|
||||
the above license grant, this restriction and the following disclaimer,
|
||||
must be included in all copies of the Software, in whole or in part, and
|
||||
all derivative works of the Software, unless such copies or derivative
|
||||
works are solely in the form of machine-executable object code generated by
|
||||
a source language processor.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
129
README.md
Normal file
@@ -0,0 +1,129 @@
|
||||
# KeePassX
|
||||
|
||||
## About
|
||||
|
||||
KeePassX is an application for people with extremely high demands on secure personal data management.
|
||||
It has a light interface, is cross platform and published under the terms of the GNU General Public License.
|
||||
|
||||
KeePassX saves many different information e.g. user names, passwords, urls, attachments and comments in one single database.
|
||||
For a better management user-defined titles and icons can be specified for each single entry.
|
||||
Furthermore the entries are sorted in groups, which are customizable as well. The integrated search function allows to search in a single group or the complete database.
|
||||
KeePassX offers a little utility for secure password generation. The password generator is very customizable, fast and easy to use.
|
||||
Especially someone who generates passwords frequently will appreciate this feature.
|
||||
|
||||
The complete database is always encrypted with the AES (aka Rijndael) encryption algorithm using a 256 bit key.
|
||||
Therefore the saved information can be considered as quite safe. KeePassX uses a database format that is compatible with [KeePass Password Safe](http://keepass.info/).
|
||||
This makes the use of that application even more favorable.
|
||||
|
||||
## Install
|
||||
|
||||
KeePassX can be downloaded and installed using an assortment of installers available on the main [KeePassX website](http://www.keepassx.org).
|
||||
KeePassX can also be installed from the official repositories of many Linux repositories.
|
||||
If you wish to build KeePassX from source, rather than rely on the pre-compiled binaries, you may wish to read up on the _From Source_ section.
|
||||
|
||||
### Debian
|
||||
|
||||
To install KeePassX from the Debian repository:
|
||||
|
||||
```bash
|
||||
sudo apt-get install keepassx
|
||||
```
|
||||
|
||||
### Red Hat
|
||||
|
||||
Install KeePassX from the Red Hat (or CentOS) repository:
|
||||
|
||||
```bash
|
||||
sudo yum install keepassx
|
||||
```
|
||||
|
||||
### Windows / Mac OS X
|
||||
|
||||
Download the installer from the KeePassX [download](https://www.keepassx.org/downloads) page.
|
||||
Once downloaded, double click on the file to execute the installer.
|
||||
|
||||
### From Source
|
||||
|
||||
#### Build Dependencies
|
||||
|
||||
The following tools must exist within your PATH:
|
||||
|
||||
* make
|
||||
* cmake (>= 2.6.4)
|
||||
* g++ or clang++
|
||||
|
||||
The following libraries are required:
|
||||
|
||||
* Qt 4 (>= 4.6)
|
||||
* libgcrypt
|
||||
* zlib
|
||||
* libxi, libxtst (optional for auto-type on X11)
|
||||
|
||||
On Debian you can install them with:
|
||||
|
||||
```bash
|
||||
sudo apt-get install build-essential cmake libqt4-dev libgcrypt11-dev zlib1g-dev libxi-dev libxtst-dev
|
||||
```
|
||||
|
||||
#### Build Steps
|
||||
|
||||
To compile from source:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make [-jX]
|
||||
```
|
||||
|
||||
You will have the compiled KeePassX binary inside the `./build/src/` directory.
|
||||
|
||||
To install this binary execute the following:
|
||||
|
||||
```bash
|
||||
sudo make install
|
||||
```
|
||||
|
||||
More detailed instructions available in the INSTALL file.
|
||||
|
||||
## Contribute
|
||||
|
||||
Coordination of work between developers is handled through the [KeePassX development](https://www.keepassx.org/dev/) site.
|
||||
Requests for enhancements, or reports of bugs encountered, can also be reported through the KeePassX development site.
|
||||
However, members of the open-source community are encouraged to submit pull requests directly through GitHub.
|
||||
|
||||
### Clone Repository
|
||||
|
||||
Clone the repository to a suitable location where you can extend and build this project.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/keepassx/keepassx.git
|
||||
```
|
||||
|
||||
**Note:** This will clone the entire contents of the repository at the HEAD revision.
|
||||
|
||||
To update the project from within the project's folder you can run the following command:
|
||||
|
||||
```bash
|
||||
git pull
|
||||
```
|
||||
|
||||
### Feature Requests
|
||||
|
||||
We're always looking for suggestions to improve our application. If you have a suggestion for improving an existing feature,
|
||||
or would like to suggest a completely new feature for KeePassX, please file a ticket on the [KeePassX development](https://www.keepassx.org/dev/) site.
|
||||
|
||||
### Bug Reports
|
||||
|
||||
Our software isn't always perfect, but we strive to always improve our work. You may file bug reports on the [KeePassX development](https://www.keepassx.org/dev/) site.
|
||||
|
||||
### Pull Requests
|
||||
|
||||
Along with our desire to hear your feedback and suggestions, we're also interested in accepting direct assistance in the form of code.
|
||||
|
||||
Issue merge requests against our [GitHub repository](https://github.com/keepassx/keepassx).
|
||||
|
||||
### Translations
|
||||
|
||||
Translations are managed on [Transifex](https://www.transifex.com/projects/p/keepassx/) which offers a web interface.
|
||||
Please join an existing language team or request a new one if there is none.
|
||||
@@ -17,7 +17,15 @@ find_path(GCRYPT_INCLUDE_DIR gcrypt.h)
|
||||
|
||||
find_library(GCRYPT_LIBRARIES gcrypt)
|
||||
|
||||
mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR)
|
||||
|
||||
if(GCRYPT_INCLUDE_DIR AND EXISTS "${GCRYPT_INCLUDE_DIR}/gcrypt.h")
|
||||
file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" GCRYPT_H REGEX "^#define GCRYPT_VERSION \"[^\"]*\"$")
|
||||
string(REGEX REPLACE "^.*GCRYPT_VERSION \"([0-9]+).*$" "\\1" GCRYPT_VERSION_MAJOR "${GCRYPT_H}")
|
||||
string(REGEX REPLACE "^.*GCRYPT_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" GCRYPT_VERSION_MINOR "${GCRYPT_H}")
|
||||
string(REGEX REPLACE "^.*GCRYPT_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GCRYPT_VERSION_PATCH "${GCRYPT_H}")
|
||||
set(GCRYPT_VERSION_STRING "${GCRYPT_VERSION_MAJOR}.${GCRYPT_VERSION_MINOR}.${GCRYPT_VERSION_PATCH}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Gcrypt DEFAULT_MSG GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR)
|
||||
|
||||
130
cmake/GetGitRevisionDescription.cmake
Normal file
@@ -0,0 +1,130 @@
|
||||
# - Returns a version string from Git
|
||||
#
|
||||
# These functions force a re-configure on each git commit so that you can
|
||||
# trust the values of the variables in your build system.
|
||||
#
|
||||
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.BOOST-1.0 or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
if(__get_git_revision_description)
|
||||
return()
|
||||
endif()
|
||||
set(__get_git_revision_description YES)
|
||||
|
||||
# We must run the following at "include" time, not at function call time,
|
||||
# to find the path to this module rather than the path to a calling list file
|
||||
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
|
||||
|
||||
function(get_git_head_revision _refspecvar _hashvar)
|
||||
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
|
||||
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
|
||||
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
|
||||
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
|
||||
# We have reached the root directory, we are not in git
|
||||
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
|
||||
endwhile()
|
||||
# check if this is a submodule
|
||||
if(NOT IS_DIRECTORY ${GIT_DIR})
|
||||
file(READ ${GIT_DIR} submodule)
|
||||
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
|
||||
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
|
||||
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
|
||||
endif()
|
||||
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
|
||||
if(NOT EXISTS "${GIT_DATA}")
|
||||
file(MAKE_DIRECTORY "${GIT_DATA}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${GIT_DIR}/HEAD")
|
||||
return()
|
||||
endif()
|
||||
set(HEAD_FILE "${GIT_DATA}/HEAD")
|
||||
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
|
||||
|
||||
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
|
||||
"${GIT_DATA}/grabRef.cmake"
|
||||
@ONLY)
|
||||
include("${GIT_DATA}/grabRef.cmake")
|
||||
|
||||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${hash}
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
41
cmake/GetGitRevisionDescription.cmake.in
Normal file
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# Internal file for GetGitRevisionDescription.cmake
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
|
||||
# http://academic.cleardefinition.com
|
||||
# Iowa State University HCI Graduate Program/VRAC
|
||||
#
|
||||
# Copyright Iowa State University 2009-2010.
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.BOOST-1.0 or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set(HEAD_HASH)
|
||||
|
||||
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
|
||||
|
||||
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
|
||||
if(HEAD_CONTENTS MATCHES "ref")
|
||||
# named branch
|
||||
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
|
||||
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
|
||||
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
else()
|
||||
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
|
||||
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
|
||||
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
|
||||
set(HEAD_HASH "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# detached HEAD
|
||||
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
|
||||
endif()
|
||||
|
||||
if(NOT HEAD_HASH)
|
||||
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
|
||||
string(STRIP "${HEAD_HASH}" HEAD_HASH)
|
||||
endif()
|
||||
@@ -13,14 +13,19 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
add_subdirectory(translations)
|
||||
|
||||
file(GLOB DATABASE_ICONS icons/database/*.png)
|
||||
|
||||
install(FILES ${DATABASE_ICONS} DESTINATION ${DATA_INSTALL_DIR}/icons/database)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(DIRECTORY icons/application/ DESTINATION share/icons/hicolor
|
||||
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
|
||||
FILES_MATCHING PATTERN "keepassx.png" PATTERN "keepassx.svgz")
|
||||
install(FILES linux/keepassx.desktop DESTINATION share/applications)
|
||||
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
|
||||
FILES_MATCHING PATTERN "application-x-keepassx.png" PATTERN "application-x-keepassx.svgz")
|
||||
install(FILES linux/keepassx.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
|
||||
install(FILES linux/keepassx.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages)
|
||||
endif(UNIX AND NOT APPLE)
|
||||
|
||||
if(APPLE)
|
||||
|
||||
|
After Width: | Height: | Size: 9.0 KiB |
BIN
share/icons/application/16x16/actions/password-copy.png
Normal file
|
After Width: | Height: | Size: 670 B |
BIN
share/icons/application/16x16/actions/password-show-off.png
Normal file
|
After Width: | Height: | Size: 783 B |
BIN
share/icons/application/16x16/actions/password-show-on.png
Normal file
|
After Width: | Height: | Size: 838 B |
BIN
share/icons/application/16x16/actions/username-copy.png
Normal file
|
After Width: | Height: | Size: 766 B |
|
After Width: | Height: | Size: 711 B |
BIN
share/icons/application/22x22/actions/document-open.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
share/icons/application/22x22/actions/document-save.png
Normal file
|
After Width: | Height: | Size: 798 B |
BIN
share/icons/application/22x22/actions/password-copy.png
Normal file
|
After Width: | Height: | Size: 966 B |
BIN
share/icons/application/22x22/actions/username-copy.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
BIN
share/icons/svg/application-x-keepassx-16.svgz
Normal file
BIN
share/icons/svg/application-x-keepassx.svgz
Normal file
BIN
share/icons/svg/password-copy.svgz
Normal file
BIN
share/icons/svg/username-copy.svgz
Normal file
@@ -1,9 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=KeePassX
|
||||
GenericName=Cross Platform Password Manager
|
||||
GenericName=Password Manager
|
||||
GenericName[de]=Passwortverwaltung
|
||||
GenericName[es]=Gestor de contraseñas multiplataforma
|
||||
GenericName[es]=Gestor de contraseñas
|
||||
GenericName[fr]=Gestionnaire de mot de passe
|
||||
GenericName[ru]=менеджер паролей
|
||||
Exec=keepassx %f
|
||||
Icon=keepassx
|
||||
Terminal=false
|
||||
|
||||
8
share/linux/keepassx.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
|
||||
<mime-type type="application/x-keepass2">
|
||||
<comment>KeePass 2 database</comment>
|
||||
<glob pattern="*.kdbx"/>
|
||||
<icon name="application-x-keepassx"/>
|
||||
</mime-type>
|
||||
</mime-info>
|
||||
26
share/translations/CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright (C) 2014 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/>.
|
||||
|
||||
file(GLOB TRANSLATION_FILES *.ts)
|
||||
get_filename_component(TRANSLATION_EN_ABS keepassx_en.ts ABSOLUTE)
|
||||
list(REMOVE_ITEM TRANSLATION_FILES keepassx_en.ts)
|
||||
list(REMOVE_ITEM TRANSLATION_FILES ${TRANSLATION_EN_ABS})
|
||||
message(STATUS ${TRANSLATION_FILES})
|
||||
|
||||
qt4_add_translation(QM_FILES ${TRANSLATION_FILES})
|
||||
|
||||
install(FILES ${QM_FILES} DESTINATION ${DATA_INSTALL_DIR}/translations)
|
||||
add_custom_target(translations DEPENDS ${QM_FILES})
|
||||
add_dependencies(${PROGNAME} translations)
|
||||
1366
share/translations/keepassx_cs.ts
Normal file
1361
share/translations/keepassx_da.ts
Normal file
1359
share/translations/keepassx_de.ts
Normal file
1286
share/translations/keepassx_el.ts
Normal file
1386
share/translations/keepassx_en.ts
Normal file
41
share/translations/keepassx_en_plurals.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="en_US">
|
||||
<context>
|
||||
<name>DatabaseWidget</name>
|
||||
<message numerus="yes">
|
||||
<source>Do you really want to move %n entry(s) to the recycle bin?</source>
|
||||
<translation>
|
||||
<numerusform>Do you really want to move %n entry to the recycle bin?</numerusform>
|
||||
<numerusform>Do you really want to move %n entries to the recycle bin?</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditEntryWidget</name>
|
||||
<message numerus="yes">
|
||||
<source>%n week(s)</source>
|
||||
<translation>
|
||||
<numerusform>%n week</numerusform>
|
||||
<numerusform>%n weeks</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<source>%n month(s)</source>
|
||||
<translation>
|
||||
<numerusform>%n month</numerusform>
|
||||
<numerusform>%n months</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EditWidgetIcons</name>
|
||||
<message numerus="yes">
|
||||
<source>Can't delete icon. Still used by %n item(s).</source>
|
||||
<translation>
|
||||
<numerusform>Can't delete icon. Still used by %n item.</numerusform>
|
||||
<numerusform>Can't delete icon. Still used by %n items.</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
1362
share/translations/keepassx_es.ts
Normal file
1362
share/translations/keepassx_fr.ts
Normal file
1362
share/translations/keepassx_id.ts
Normal file
1362
share/translations/keepassx_it.ts
Normal file
1362
share/translations/keepassx_ja.ts
Normal file
1359
share/translations/keepassx_ko.ts
Normal file
1362
share/translations/keepassx_lt.ts
Normal file
1362
share/translations/keepassx_nl_NL.ts
Normal file
1362
share/translations/keepassx_pl.ts
Normal file
1362
share/translations/keepassx_pt_BR.ts
Normal file
1356
share/translations/keepassx_pt_PT.ts
Normal file
1361
share/translations/keepassx_ru.ts
Normal file
1356
share/translations/keepassx_sl_SI.ts
Normal file
1362
share/translations/keepassx_sv.ts
Normal file
1360
share/translations/keepassx_uk.ts
Normal file
1361
share/translations/keepassx_zh_CN.ts
Normal file
1362
share/translations/keepassx_zh_TW.ts
Normal file
12
share/translations/update.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASEDIR=$(dirname $0)
|
||||
|
||||
cd $BASEDIR/../..
|
||||
|
||||
echo Updating source file
|
||||
lupdate -no-ui-lines -disable-heuristic similartext -locations none -no-obsolete src -ts share/translations/keepassx_en.ts
|
||||
lupdate -no-ui-lines -disable-heuristic similartext -locations none -pluralonly src -ts share/translations/keepassx_en_plurals.ts
|
||||
|
||||
echo Pulling translations from Transifex
|
||||
tx pull -a --minimum-perc=80
|
||||
@@ -17,6 +17,17 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h)
|
||||
|
||||
include(GetGitRevisionDescription)
|
||||
get_git_head_revision(GIT_REFSPEC GIT_HEAD)
|
||||
git_describe(GIT_DESCRIBE --long)
|
||||
|
||||
if (NOT GIT_HEAD OR NOT GIT_DESCRIBE)
|
||||
set(GIT_HEAD "")
|
||||
set(GIT_DESCRIBE "")
|
||||
endif()
|
||||
|
||||
configure_file(version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h @ONLY)
|
||||
|
||||
set(keepassx_SOURCES
|
||||
autotype/AutoType.cpp
|
||||
autotype/AutoTypeAction.cpp
|
||||
@@ -27,7 +38,6 @@ set(keepassx_SOURCES
|
||||
autotype/WildcardMatcher.cpp
|
||||
autotype/WindowSelectComboBox.cpp
|
||||
autotype/test/AutoTypeTestInterface.h
|
||||
core/ArgumentParser.cpp
|
||||
core/AutoTypeAssociations.cpp
|
||||
core/Config.cpp
|
||||
core/Database.cpp
|
||||
@@ -36,36 +46,39 @@ set(keepassx_SOURCES
|
||||
core/Entry.cpp
|
||||
core/EntryAttachments.cpp
|
||||
core/EntryAttributes.cpp
|
||||
core/EntrySearcher.cpp
|
||||
core/FilePath.cpp
|
||||
core/Global.h
|
||||
core/Group.cpp
|
||||
core/InactivityTimer.cpp
|
||||
core/ListDeleter.h
|
||||
core/Metadata.cpp
|
||||
core/PasswordGenerator.cpp
|
||||
core/qlockfile.cpp
|
||||
core/qsavefile.cpp
|
||||
core/qsavefile_p.h
|
||||
core/SignalMultiplexer.cpp
|
||||
core/TimeDelta.cpp
|
||||
core/TimeInfo.cpp
|
||||
core/ToDbExporter.cpp
|
||||
core/Tools.cpp
|
||||
core/Translator.cpp
|
||||
core/Uuid.cpp
|
||||
core/qcommandlineoption.cpp
|
||||
core/qcommandlineparser.cpp
|
||||
crypto/Crypto.cpp
|
||||
crypto/CryptoHash.cpp
|
||||
crypto/Random.cpp
|
||||
crypto/salsa20/ecrypt-config.h
|
||||
crypto/salsa20/ecrypt-machine.h
|
||||
crypto/salsa20/ecrypt-portable.h
|
||||
crypto/salsa20/ecrypt-sync.h
|
||||
crypto/salsa20/salsa20.c
|
||||
crypto/SymmetricCipher.cpp
|
||||
crypto/SymmetricCipherBackend.h
|
||||
crypto/SymmetricCipherGcrypt.cpp
|
||||
crypto/SymmetricCipherSalsa20.cpp
|
||||
format/CsvExporter.cpp
|
||||
format/KeePass1.h
|
||||
format/KeePass1Reader.cpp
|
||||
format/KeePass2.h
|
||||
format/KeePass2RandomStream.cpp
|
||||
format/KeePass2Reader.cpp
|
||||
format/KeePass2Repair.cpp
|
||||
format/KeePass2Writer.cpp
|
||||
format/KeePass2XmlReader.cpp
|
||||
format/KeePass2XmlWriter.cpp
|
||||
@@ -74,9 +87,11 @@ set(keepassx_SOURCES
|
||||
gui/ChangeMasterKeyWidget.cpp
|
||||
gui/Clipboard.cpp
|
||||
gui/DatabaseOpenWidget.cpp
|
||||
gui/DatabaseRepairWidget.cpp
|
||||
gui/DatabaseSettingsWidget.cpp
|
||||
gui/DatabaseTabWidget.cpp
|
||||
gui/DatabaseWidget.cpp
|
||||
gui/DatabaseWidgetStateSync.cpp
|
||||
gui/DialogyWidget.cpp
|
||||
gui/DragTabBar.cpp
|
||||
gui/EditWidget.cpp
|
||||
@@ -88,7 +103,9 @@ set(keepassx_SOURCES
|
||||
gui/LineEdit.cpp
|
||||
gui/MainWindow.cpp
|
||||
gui/MessageBox.cpp
|
||||
gui/PasswordEdit.cpp
|
||||
gui/PasswordGeneratorWidget.cpp
|
||||
gui/PasswordComboBox.cpp
|
||||
gui/SettingsWidget.cpp
|
||||
gui/SortFilterHideProxyModel.cpp
|
||||
gui/UnlockDatabaseWidget.cpp
|
||||
@@ -116,6 +133,30 @@ set(keepassx_SOURCES
|
||||
streams/SymmetricCipherStream.cpp
|
||||
)
|
||||
|
||||
if(NOT GCRYPT_HAS_SALSA20)
|
||||
set(keepassx_SOURCES
|
||||
${keepassx_SOURCES}
|
||||
crypto/salsa20/ecrypt-config.h
|
||||
crypto/salsa20/ecrypt-machine.h
|
||||
crypto/salsa20/ecrypt-portable.h
|
||||
crypto/salsa20/ecrypt-sync.h
|
||||
crypto/salsa20/salsa20.c
|
||||
crypto/SymmetricCipherSalsa20.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
set(keepassx_SOURCES
|
||||
${keepassx_SOURCES}
|
||||
core/qlockfile_unix.cpp
|
||||
)
|
||||
elseif(MINGW)
|
||||
set(keepassx_SOURCES
|
||||
${keepassx_SOURCES}
|
||||
core/qlockfile_win.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(keepassx_SOURCES_MAINEXE
|
||||
main.cpp
|
||||
)
|
||||
@@ -133,6 +174,7 @@ set(keepassx_MOC
|
||||
core/EntryAttachments.h
|
||||
core/EntryAttributes.h
|
||||
core/Group.h
|
||||
core/InactivityTimer.h
|
||||
core/Metadata.h
|
||||
core/qsavefile.h
|
||||
gui/AboutDialog.h
|
||||
@@ -140,9 +182,11 @@ set(keepassx_MOC
|
||||
gui/ChangeMasterKeyWidget.h
|
||||
gui/Clipboard.h
|
||||
gui/DatabaseOpenWidget.h
|
||||
gui/DatabaseRepairWidget.h
|
||||
gui/DatabaseSettingsWidget.h
|
||||
gui/DatabaseTabWidget.h
|
||||
gui/DatabaseWidget.h
|
||||
gui/DatabaseWidgetStateSync.h
|
||||
gui/DialogyWidget.h
|
||||
gui/DragTabBar.h
|
||||
gui/EditWidget.h
|
||||
@@ -152,7 +196,9 @@ set(keepassx_MOC
|
||||
gui/KeePass1OpenWidget.h
|
||||
gui/LineEdit.h
|
||||
gui/MainWindow.h
|
||||
gui/PasswordEdit.h
|
||||
gui/PasswordGeneratorWidget.h
|
||||
gui/PasswordComboBox.h
|
||||
gui/SettingsWidget.h
|
||||
gui/SortFilterHideProxyModel.h
|
||||
gui/UnlockDatabaseWidget.h
|
||||
@@ -216,10 +262,6 @@ target_link_libraries(${PROGNAME}
|
||||
${GCRYPT_LIBRARIES}
|
||||
${ZLIB_LIBRARIES})
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(${PROGNAME} ${QT_QTDBUS_LIBRARY})
|
||||
endif()
|
||||
|
||||
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
|
||||
|
||||
if(APPLE)
|
||||
|
||||
@@ -23,12 +23,14 @@
|
||||
#include "autotype/AutoTypePlatformPlugin.h"
|
||||
#include "autotype/AutoTypeSelectDialog.h"
|
||||
#include "autotype/WildcardMatcher.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Entry.h"
|
||||
#include "core/FilePath.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/ListDeleter.h"
|
||||
#include "core/Tools.h"
|
||||
#include "gui/MessageBox.h"
|
||||
|
||||
AutoType* AutoType::m_instance = Q_NULLPTR;
|
||||
|
||||
@@ -40,6 +42,7 @@ AutoType::AutoType(QObject* parent, bool test)
|
||||
, m_pluginLoader(new QPluginLoader(this))
|
||||
, m_plugin(Q_NULLPTR)
|
||||
, m_executor(Q_NULLPTR)
|
||||
, m_windowFromGlobal(0)
|
||||
{
|
||||
// prevent crash when the plugin has unresolved symbols
|
||||
m_pluginLoader->setLoadHints(QLibrary::ResolveAllSymbolsHint);
|
||||
@@ -76,9 +79,16 @@ void AutoType::loadPlugin(const QString& pluginPath)
|
||||
QObject* pluginInstance = m_pluginLoader->instance();
|
||||
if (pluginInstance) {
|
||||
m_plugin = qobject_cast<AutoTypePlatformInterface*>(pluginInstance);
|
||||
m_executor = Q_NULLPTR;
|
||||
|
||||
if (m_plugin) {
|
||||
m_executor = m_plugin->createExecutor();
|
||||
connect(pluginInstance, SIGNAL(globalShortcutTriggered()), SIGNAL(globalShortcutTriggered()));
|
||||
if (m_plugin->isAvailable()) {
|
||||
m_executor = m_plugin->createExecutor();
|
||||
connect(pluginInstance, SIGNAL(globalShortcutTriggered()), SIGNAL(globalShortcutTriggered()));
|
||||
}
|
||||
else {
|
||||
unloadPlugin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +155,8 @@ void AutoType::performAutoType(const Entry* entry, QWidget* hideWindow, const QS
|
||||
window = m_plugin->activeWindow();
|
||||
}
|
||||
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 10);
|
||||
|
||||
Q_FOREACH (AutoTypeAction* action, actions) {
|
||||
if (m_plugin->activeWindow() != window) {
|
||||
qWarning("Active window changed, interrupting auto-type.");
|
||||
@@ -187,8 +199,12 @@ void AutoType::performGlobalAutoType(const QList<Database*>& dbList)
|
||||
|
||||
if (entryList.isEmpty()) {
|
||||
m_inAutoType = false;
|
||||
QString message = tr("Couldn't find an entry that matches the window title:");
|
||||
message.append("\n\n");
|
||||
message.append(windowTitle);
|
||||
MessageBox::information(Q_NULLPTR, tr("Auto-Type - KeePassX"), message);
|
||||
}
|
||||
else if (entryList.size() == 1) {
|
||||
else if ((entryList.size() == 1) && !config()->get("security/autotypeask").toBool()) {
|
||||
m_inAutoType = false;
|
||||
performAutoType(entryList.first(), Q_NULLPTR, sequenceHash[entryList.first()]);
|
||||
}
|
||||
@@ -209,6 +225,8 @@ void AutoType::performAutoTypeFromGlobal(Entry* entry, const QString& sequence)
|
||||
{
|
||||
Q_ASSERT(m_inAutoType);
|
||||
|
||||
m_plugin->raiseWindow(m_windowFromGlobal);
|
||||
|
||||
m_inAutoType = false;
|
||||
performAutoType(entry, Q_NULLPTR, sequence, m_windowFromGlobal);
|
||||
}
|
||||
@@ -468,7 +486,15 @@ QList<AutoTypeAction*> AutoType::createActionFromTemplate(const QString& tmpl, c
|
||||
QString resolved = entry->resolvePlaceholders(placeholder);
|
||||
if (placeholder != resolved) {
|
||||
Q_FOREACH (const QChar& ch, resolved) {
|
||||
list.append(new AutoTypeChar(ch));
|
||||
if (ch == '\n') {
|
||||
list.append(new AutoTypeKey(Qt::Key_Enter));
|
||||
}
|
||||
else if (ch == '\t') {
|
||||
list.append(new AutoTypeKey(Qt::Key_Tab));
|
||||
}
|
||||
else {
|
||||
list.append(new AutoTypeChar(ch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,6 +524,12 @@ QString AutoType::autoTypeSequence(const Entry* entry, const QString& windowTitl
|
||||
}
|
||||
}
|
||||
|
||||
if (!match && config()->get("AutoTypeEntryTitleMatch").toBool() && !entry->title().isEmpty()
|
||||
&& windowTitle.contains(entry->title(), Qt::CaseInsensitive)) {
|
||||
sequence = entry->defaultAutoTypeSequence();
|
||||
match = true;
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
return QString();
|
||||
}
|
||||
@@ -543,7 +575,7 @@ bool AutoType::windowMatches(const QString& windowTitle, const QString& windowPa
|
||||
{
|
||||
if (windowPattern.startsWith("//") && windowPattern.endsWith("//") && windowPattern.size() >= 4) {
|
||||
QRegExp regExp(windowPattern.mid(2, windowPattern.size() - 4), Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||
return regExp.exactMatch(windowTitle);
|
||||
return (regExp.indexIn(windowTitle) != -1);
|
||||
}
|
||||
else {
|
||||
return WildcardMatcher(windowTitle).match(windowPattern);
|
||||
|
||||
@@ -89,5 +89,7 @@ void AutoTypeExecutor::execDelay(AutoTypeDelay* action)
|
||||
|
||||
void AutoTypeExecutor::execClearField(AutoTypeClearField* action)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ class AutoTypePlatformInterface
|
||||
{
|
||||
public:
|
||||
virtual ~AutoTypePlatformInterface() {}
|
||||
virtual bool isAvailable() = 0;
|
||||
virtual QStringList windowTitles() = 0;
|
||||
virtual WId activeWindow() = 0;
|
||||
virtual QString activeWindowTitle() = 0;
|
||||
@@ -33,6 +34,7 @@ public:
|
||||
virtual void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) = 0;
|
||||
virtual int platformEventFilter(void* event) = 0;
|
||||
virtual int initialTimeout() = 0;
|
||||
virtual bool raiseWindow(WId window) = 0;
|
||||
virtual void unload() {}
|
||||
|
||||
virtual AutoTypeExecutor* createExecutor() = 0;
|
||||
|
||||
@@ -33,6 +33,8 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
|
||||
, m_entryActivatedEmitted(false)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
// Places the window on the active (virtual) desktop instead of where the main window is.
|
||||
setAttribute(Qt::WA_X11BypassTransientForHint);
|
||||
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
setWindowTitle(tr("Auto-Type - KeePassX"));
|
||||
setWindowIcon(filePath()->applicationIcon());
|
||||
@@ -41,7 +43,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
|
||||
resize(size);
|
||||
|
||||
// move dialog to the center of the screen
|
||||
QPoint screenCenter = QApplication::desktop()->screenGeometry(QCursor::pos()).center();
|
||||
QPoint screenCenter = QApplication::desktop()->availableGeometry(QCursor::pos()).center();
|
||||
move(screenCenter.x() - (size.width() / 2), screenCenter.y() - (size.height() / 2));
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
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")
|
||||
add_feature_info(libXi X11_Xi_FOUND "The X11 Xi Protocol library is required for auto-type")
|
||||
add_feature_info(libXtst X11_XTest_FOUND "The X11 XTEST Protocol library is required for auto-type")
|
||||
endif()
|
||||
|
||||
if(X11_FOUND AND X11_XTest_FOUND)
|
||||
if(X11_FOUND AND X11_Xi_FOUND AND X11_XTest_FOUND)
|
||||
add_subdirectory(x11)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
#include "AutoTypeTest.h"
|
||||
|
||||
bool AutoTypePlatformTest::isAvailable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QString AutoTypePlatformTest::keyToString(Qt::Key key)
|
||||
{
|
||||
return QString("[Key0x%1]").arg(key, 0, 16);
|
||||
@@ -103,6 +108,13 @@ int AutoTypePlatformTest::initialTimeout()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AutoTypePlatformTest::raiseWindow(WId window)
|
||||
{
|
||||
Q_UNUSED(window);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoTypeExecturorTest::AutoTypeExecturorTest(AutoTypePlatformTest* platform)
|
||||
: m_platform(platform)
|
||||
{
|
||||
|
||||
@@ -33,22 +33,24 @@ class AutoTypePlatformTest : public QObject,
|
||||
Q_INTERFACES(AutoTypePlatformInterface AutoTypeTestInterface)
|
||||
|
||||
public:
|
||||
QString keyToString(Qt::Key key);
|
||||
QString keyToString(Qt::Key key) Q_DECL_OVERRIDE;
|
||||
|
||||
QStringList windowTitles();
|
||||
WId activeWindow();
|
||||
QString activeWindowTitle();
|
||||
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
||||
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
||||
int platformEventFilter(void* event);
|
||||
int initialTimeout();
|
||||
AutoTypeExecutor* createExecutor();
|
||||
bool isAvailable() Q_DECL_OVERRIDE;
|
||||
QStringList windowTitles() Q_DECL_OVERRIDE;
|
||||
WId activeWindow() Q_DECL_OVERRIDE;
|
||||
QString activeWindowTitle() Q_DECL_OVERRIDE;
|
||||
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
int platformEventFilter(void* event) Q_DECL_OVERRIDE;
|
||||
int initialTimeout() Q_DECL_OVERRIDE;
|
||||
bool raiseWindow(WId window) Q_DECL_OVERRIDE;
|
||||
AutoTypeExecutor* createExecutor() Q_DECL_OVERRIDE;
|
||||
|
||||
void setActiveWindowTitle(const QString& title);
|
||||
void setActiveWindowTitle(const QString& title) Q_DECL_OVERRIDE;
|
||||
|
||||
QString actionChars();
|
||||
int actionCount();
|
||||
void clearActions();
|
||||
QString actionChars() Q_DECL_OVERRIDE;
|
||||
int actionCount() Q_DECL_OVERRIDE;
|
||||
void clearActions() Q_DECL_OVERRIDE;
|
||||
|
||||
void addActionChar(AutoTypeChar* action);
|
||||
void addActionKey(AutoTypeKey* action);
|
||||
@@ -67,8 +69,8 @@ class AutoTypeExecturorTest : public AutoTypeExecutor
|
||||
public:
|
||||
explicit AutoTypeExecturorTest(AutoTypePlatformTest* platform);
|
||||
|
||||
void execChar(AutoTypeChar* action);
|
||||
void execKey(AutoTypeKey* action);
|
||||
void execChar(AutoTypeChar* action) Q_DECL_OVERRIDE;
|
||||
void execKey(AutoTypeKey* action) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
AutoTypePlatformTest* const m_platform;
|
||||
|
||||
@@ -30,15 +30,17 @@ AutoTypePlatformX11::AutoTypePlatformX11()
|
||||
m_dpy = QX11Info::display();
|
||||
m_rootWindow = QX11Info::appRootWindow();
|
||||
|
||||
m_atomWmState = XInternAtom(m_dpy, "WM_STATE", true);
|
||||
m_atomWmName = XInternAtom(m_dpy, "WM_NAME", true);
|
||||
m_atomNetWmName = XInternAtom(m_dpy, "_NET_WM_NAME", true);
|
||||
m_atomString = XInternAtom(m_dpy, "STRING", true);
|
||||
m_atomUtf8String = XInternAtom(m_dpy, "UTF8_STRING", true);
|
||||
m_atomWmState = XInternAtom(m_dpy, "WM_STATE", True);
|
||||
m_atomWmName = XInternAtom(m_dpy, "WM_NAME", True);
|
||||
m_atomNetWmName = XInternAtom(m_dpy, "_NET_WM_NAME", True);
|
||||
m_atomString = XInternAtom(m_dpy, "STRING", True);
|
||||
m_atomUtf8String = XInternAtom(m_dpy, "UTF8_STRING", True);
|
||||
m_atomNetActiveWindow = XInternAtom(m_dpy, "_NET_ACTIVE_WINDOW", True);
|
||||
|
||||
m_classBlacklist << "desktop_window" << "gnome-panel"; // Gnome
|
||||
m_classBlacklist << "kdesktop" << "kicker"; // KDE 3
|
||||
m_classBlacklist << "Plasma"; // KDE 4
|
||||
m_classBlacklist << "plasmashell"; // KDE 5
|
||||
m_classBlacklist << "xfdesktop" << "xfce4-panel"; // Xfce 4
|
||||
|
||||
m_currentGlobalKey = static_cast<Qt::Key>(0);
|
||||
@@ -46,7 +48,8 @@ AutoTypePlatformX11::AutoTypePlatformX11()
|
||||
|
||||
m_keysymTable = Q_NULLPTR;
|
||||
m_xkb = Q_NULLPTR;
|
||||
m_specialCharacterKeycode = 0;
|
||||
m_remapKeycode = 0;
|
||||
m_currentRemapKeysym = NoSymbol;
|
||||
m_modifierMask = ControlMask | ShiftMask | Mod1Mask | Mod4Mask;
|
||||
|
||||
m_loaded = true;
|
||||
@@ -54,10 +57,37 @@ AutoTypePlatformX11::AutoTypePlatformX11()
|
||||
updateKeymap();
|
||||
}
|
||||
|
||||
bool AutoTypePlatformX11::isAvailable()
|
||||
{
|
||||
int ignore;
|
||||
|
||||
if (!XQueryExtension(m_dpy, "XInputExtension", &ignore, &ignore, &ignore)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!XQueryExtension(m_dpy, "XTEST", &ignore, &ignore, &ignore)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_xkb) {
|
||||
XkbDescPtr kbd = getKeyboard();
|
||||
|
||||
if (!kbd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XkbFreeKeyboard(kbd, XkbAllComponentsMask, True);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AutoTypePlatformX11::unload()
|
||||
{
|
||||
// Restore the KeyboardMapping to its original state.
|
||||
AddKeysym(NoSymbol);
|
||||
if (m_currentRemapKeysym != NoSymbol) {
|
||||
AddKeysym(NoSymbol);
|
||||
}
|
||||
|
||||
if (m_keysymTable) {
|
||||
XFree(m_keysymTable);
|
||||
@@ -112,12 +142,12 @@ bool AutoTypePlatformX11::registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifi
|
||||
uint nativeModifiers = qtToNativeModifiers(modifiers);
|
||||
|
||||
startCatchXErrors();
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers, m_rootWindow, true, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask, m_rootWindow, true, GrabModeAsync,
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers, m_rootWindow, True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask, m_rootWindow, True, GrabModeAsync,
|
||||
GrabModeAsync);
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers | LockMask, m_rootWindow, true, GrabModeAsync,
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers | LockMask, m_rootWindow, True, GrabModeAsync,
|
||||
GrabModeAsync);
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask | LockMask, m_rootWindow, true,
|
||||
XGrabKey(m_dpy, keycode, nativeModifiers | Mod2Mask | LockMask, m_rootWindow, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
stopCatchXErrors();
|
||||
|
||||
@@ -156,7 +186,7 @@ uint AutoTypePlatformX11::qtToNativeModifiers(Qt::KeyboardModifiers modifiers)
|
||||
|
||||
void AutoTypePlatformX11::unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
KeyCode keycode = XKeysymToKeycode(m_dpy, keyToKeySym(key));
|
||||
KeyCode keycode = XKeysymToKeycode(m_dpy, charToKeySym(key));
|
||||
uint nativeModifiers = qtToNativeModifiers(modifiers);
|
||||
|
||||
XUngrabKey(m_dpy, keycode, nativeModifiers, m_rootWindow);
|
||||
@@ -178,7 +208,7 @@ int AutoTypePlatformX11::platformEventFilter(void* event)
|
||||
&& m_currentGlobalKey
|
||||
&& xevent->xkey.keycode == m_currentGlobalKeycode
|
||||
&& (xevent->xkey.state & m_modifierMask) == m_currentGlobalNativeModifiers
|
||||
&& !QApplication::focusWidget()
|
||||
&& (!QApplication::activeWindow() || QApplication::activeWindow()->isMinimized())
|
||||
&& m_loaded) {
|
||||
if (xevent->type == KeyPress) {
|
||||
Q_EMIT globalShortcutTriggered();
|
||||
@@ -208,23 +238,26 @@ QString AutoTypePlatformX11::windowTitle(Window window, bool useBlacklist)
|
||||
unsigned long after;
|
||||
unsigned char* data = Q_NULLPTR;
|
||||
|
||||
int retVal = XGetWindowProperty(m_dpy, window, m_atomNetWmName, 0, 1000, false, m_atomUtf8String,
|
||||
// the window manager spec says we should read _NET_WM_NAME first, then fall back to WM_NAME
|
||||
|
||||
int retVal = XGetWindowProperty(m_dpy, window, m_atomNetWmName, 0, 1000, False, m_atomUtf8String,
|
||||
&type, &format, &nitems, &after, &data);
|
||||
|
||||
if (retVal != 0 && data) {
|
||||
if ((retVal == 0) && data) {
|
||||
title = QString::fromUtf8(reinterpret_cast<char*>(data));
|
||||
}
|
||||
else {
|
||||
XTextProperty textProp;
|
||||
retVal = XGetTextProperty(m_dpy, window, &textProp, m_atomWmName);
|
||||
if (retVal != 0 && textProp.value) {
|
||||
if ((retVal != 0) && textProp.value) {
|
||||
char** textList = Q_NULLPTR;
|
||||
int count;
|
||||
|
||||
if (textProp.encoding == m_atomUtf8String) {
|
||||
title = QString::fromUtf8(reinterpret_cast<char*>(textProp.value));
|
||||
}
|
||||
else if (XmbTextPropertyToTextList(m_dpy, &textProp, &textList, &count) == 0 && textList && count > 0) {
|
||||
else if ((XmbTextPropertyToTextList(m_dpy, &textProp, &textList, &count) == 0)
|
||||
&& textList && (count > 0)) {
|
||||
title = QString::fromLocal8Bit(textList[0]);
|
||||
}
|
||||
else if (textProp.encoding == m_atomString) {
|
||||
@@ -330,13 +363,21 @@ bool AutoTypePlatformX11::isTopLevelWindow(Window window)
|
||||
unsigned long nitems;
|
||||
unsigned long after;
|
||||
unsigned char* data = Q_NULLPTR;
|
||||
int retVal = XGetWindowProperty(m_dpy, window, m_atomWmState, 0, 0, false, AnyPropertyType, &type, &format,
|
||||
int retVal = XGetWindowProperty(m_dpy, window, m_atomWmState, 0, 2, False, m_atomWmState, &type, &format,
|
||||
&nitems, &after, &data);
|
||||
if (data) {
|
||||
|
||||
bool result = false;
|
||||
|
||||
if (retVal == 0 && data) {
|
||||
if (type == m_atomWmState && format == 32 && nitems > 0) {
|
||||
qint32 state = static_cast<qint32>(*data);
|
||||
result = (state != WithdrawnState);
|
||||
}
|
||||
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
return (retVal == 0) && type;
|
||||
return result;
|
||||
}
|
||||
|
||||
KeySym AutoTypePlatformX11::charToKeySym(const QChar& ch)
|
||||
@@ -429,9 +470,10 @@ void AutoTypePlatformX11::updateKeymap()
|
||||
int mod_index, mod_key;
|
||||
XModifierKeymap *modifiers;
|
||||
|
||||
/* read keyboard map */
|
||||
if (m_xkb != NULL) XkbFreeKeyboard(m_xkb, XkbAllComponentsMask, True);
|
||||
m_xkb = XkbGetKeyboard (m_dpy, XkbCompatMapMask | XkbGeometryMask, XkbUseCoreKbd);
|
||||
if (m_xkb) {
|
||||
XkbFreeKeyboard(m_xkb, XkbAllComponentsMask, True);
|
||||
}
|
||||
m_xkb = getKeyboard();
|
||||
|
||||
XDisplayKeycodes(m_dpy, &m_minKeycode, &m_maxKeycode);
|
||||
if (m_keysymTable != NULL) XFree(m_keysymTable);
|
||||
@@ -440,11 +482,13 @@ void AutoTypePlatformX11::updateKeymap()
|
||||
&m_keysymPerKeycode);
|
||||
|
||||
/* determine the keycode to use for remapped keys */
|
||||
if (m_specialCharacterKeycode == 0) {
|
||||
inx = (m_remapKeycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_remapKeycode == 0 || !isRemapKeycodeValid()) {
|
||||
for (keycode = m_minKeycode; keycode <= m_maxKeycode; keycode++) {
|
||||
inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
if (m_keysymTable[inx] == NoSymbol) {
|
||||
m_specialCharacterKeycode = keycode;
|
||||
m_remapKeycode = keycode;
|
||||
m_currentRemapKeysym = NoSymbol;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -463,6 +507,26 @@ void AutoTypePlatformX11::updateKeymap()
|
||||
}
|
||||
}
|
||||
XFreeModifiermap(modifiers);
|
||||
|
||||
/* Xlib needs some time until the mapping is distributed to
|
||||
all clients */
|
||||
// TODO: we should probably only sleep while in the middle of typing something
|
||||
timespec ts;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 30 * 1000 * 1000;
|
||||
nanosleep(&ts, Q_NULLPTR);
|
||||
}
|
||||
|
||||
bool AutoTypePlatformX11::isRemapKeycodeValid()
|
||||
{
|
||||
int baseKeycode = (m_remapKeycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
for (int i = 0; i < m_keysymPerKeycode; i++) {
|
||||
if (m_keysymTable[baseKeycode + i] == m_currentRemapKeysym) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AutoTypePlatformX11::startCatchXErrors()
|
||||
@@ -478,7 +542,7 @@ void AutoTypePlatformX11::stopCatchXErrors()
|
||||
{
|
||||
Q_ASSERT(m_catchXErrors);
|
||||
|
||||
XSync(m_dpy, false);
|
||||
XSync(m_dpy, False);
|
||||
XSetErrorHandler(m_oldXErrorHandler);
|
||||
m_catchXErrors = false;
|
||||
}
|
||||
@@ -495,6 +559,27 @@ int AutoTypePlatformX11::x11ErrorHandler(Display* display, XErrorEvent* error)
|
||||
return 1;
|
||||
}
|
||||
|
||||
XkbDescPtr AutoTypePlatformX11::getKeyboard()
|
||||
{
|
||||
int num_devices;
|
||||
XID keyboard_id = XkbUseCoreKbd;
|
||||
XDeviceInfo* devices = XListInputDevices(m_dpy, &num_devices);
|
||||
if (!devices) {
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_devices; i++) {
|
||||
if (QString(devices[i].name) == "Virtual core XTEST keyboard") {
|
||||
keyboard_id = devices[i].id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFreeDeviceList(devices);
|
||||
|
||||
return XkbGetKeyboard(m_dpy, XkbCompatMapMask | XkbGeometryMask, keyboard_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// The following code is taken from xvkbd 3.0 and has been slightly modified.
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -505,23 +590,19 @@ int AutoTypePlatformX11::x11ErrorHandler(Display* display, XErrorEvent* error)
|
||||
*/
|
||||
int AutoTypePlatformX11::AddKeysym(KeySym keysym)
|
||||
{
|
||||
if (m_specialCharacterKeycode == 0) {
|
||||
if (m_remapKeycode == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inx = (m_specialCharacterKeycode - m_minKeycode) * m_keysymPerKeycode;
|
||||
int inx = (m_remapKeycode- m_minKeycode) * m_keysymPerKeycode;
|
||||
m_keysymTable[inx] = keysym;
|
||||
XChangeKeyboardMapping(m_dpy, m_specialCharacterKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
|
||||
m_currentRemapKeysym = keysym;
|
||||
|
||||
XChangeKeyboardMapping(m_dpy, m_remapKeycode, m_keysymPerKeycode, &m_keysymTable[inx], 1);
|
||||
XFlush(m_dpy);
|
||||
updateKeymap();
|
||||
|
||||
/* 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);
|
||||
|
||||
return m_specialCharacterKeycode;
|
||||
return m_remapKeycode;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -531,11 +612,18 @@ int AutoTypePlatformX11::AddKeysym(KeySym keysym)
|
||||
*/
|
||||
void AutoTypePlatformX11::SendEvent(XKeyEvent* event, int event_type)
|
||||
{
|
||||
XSync(event->display, FALSE);
|
||||
XSync(event->display, False);
|
||||
int (*oldHandler) (Display*, XErrorEvent*) = XSetErrorHandler(MyErrorHandler);
|
||||
|
||||
event->type = event_type;
|
||||
XTestFakeKeyEvent(event->display, event->keycode, event->type == KeyPress, 0);
|
||||
Bool press;
|
||||
if (event->type == KeyPress) {
|
||||
press = True;
|
||||
}
|
||||
else {
|
||||
press = False;
|
||||
}
|
||||
XTestFakeKeyEvent(event->display, event->keycode, press, 0);
|
||||
XFlush(event->display);
|
||||
|
||||
XSetErrorHandler(oldHandler);
|
||||
@@ -564,30 +652,43 @@ void AutoTypePlatformX11::SendModifier(XKeyEvent *event, unsigned int mask, int
|
||||
* Determines the keycode and modifier mask for the given
|
||||
* keysym.
|
||||
*/
|
||||
int AutoTypePlatformX11::GetKeycode(KeySym keysym, unsigned int *mask)
|
||||
int AutoTypePlatformX11::GetKeycode(KeySym keysym, unsigned int *mask)
|
||||
{
|
||||
int keycode = XKeysymToKeycode(m_dpy, keysym);
|
||||
|
||||
if (keycode && keysymModifiers(keysym, keycode, mask)) {
|
||||
return keycode;
|
||||
}
|
||||
|
||||
/* no modifier matches => resort to remapping */
|
||||
keycode = AddKeysym(keysym);
|
||||
if (keycode && keysymModifiers(keysym, keycode, mask)) {
|
||||
return keycode;
|
||||
}
|
||||
|
||||
*mask = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AutoTypePlatformX11::keysymModifiers(KeySym keysym, int keycode, 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 ++) {
|
||||
KeySym keysym_rtrn;
|
||||
*mask = (mod == ControlMapIndex) ? shift : shift | (1 << mod);
|
||||
XkbTranslateKeyCode(m_xkb, keycode, *mask, &mods_rtrn, &keysym_rtrn);
|
||||
if (keysym_rtrn == keysym) {
|
||||
return keycode;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no modifier matches => resort to remapping */
|
||||
*mask = 0;
|
||||
return AddKeysym(keysym);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -605,10 +706,12 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym)
|
||||
int keycode;
|
||||
|
||||
if (keysym == NoSymbol) {
|
||||
qWarning("No such key: keysym=0x%lX", static_cast<long>(keysym));
|
||||
qWarning("No such key: keysym=0x%lX", keysym);
|
||||
return;
|
||||
}
|
||||
|
||||
XGetInputFocus(m_dpy, &cur_focus, &revert_to);
|
||||
|
||||
event.display = m_dpy;
|
||||
event.window = cur_focus;
|
||||
event.root = m_rootWindow;
|
||||
@@ -622,24 +725,56 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym)
|
||||
|
||||
Window root, child;
|
||||
int root_x, root_y, x, y;
|
||||
unsigned int mask;
|
||||
unsigned int saved_mask;
|
||||
unsigned int wanted_mask = 0;
|
||||
unsigned int original_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);
|
||||
XQueryPointer(m_dpy, event.root, &root, &child, &root_x, &root_y, &x, &y, &original_mask);
|
||||
|
||||
/* determine keycode and mask for the given keysym */
|
||||
keycode = GetKeycode(keysym, &mask);
|
||||
keycode = GetKeycode(keysym, &wanted_mask);
|
||||
if (keycode < 8 || keycode > 255) {
|
||||
qWarning("Unable to get valid keycode for key: keysym=0x%lX", static_cast<long>(keysym));
|
||||
qWarning("Unable to get valid keycode for key: keysym=0x%lX", keysym);
|
||||
return;
|
||||
}
|
||||
|
||||
/* release all modifiers */
|
||||
SendModifier(&event, mask, KeyRelease);
|
||||
event.state = original_mask;
|
||||
|
||||
SendModifier(&event, mask, KeyPress);
|
||||
// modifiers that need to be pressed but aren't
|
||||
unsigned int press_mask = wanted_mask & ~original_mask;
|
||||
|
||||
// modifiers that are pressed but maybe shouldn't
|
||||
unsigned int release_check_mask = original_mask & ~wanted_mask;
|
||||
|
||||
// modifiers we need to release before sending the keycode
|
||||
unsigned int release_mask = 0;
|
||||
|
||||
// check every release_check_mask individually if it affects the keysym we would generate
|
||||
// if it doesn't we probably don't need to release it
|
||||
for (int mod_index = ShiftMapIndex; mod_index <= Mod5MapIndex; mod_index ++) {
|
||||
if (release_check_mask & (1 << mod_index)) {
|
||||
unsigned int mods_rtrn;
|
||||
KeySym keysym_rtrn;
|
||||
XkbTranslateKeyCode(m_xkb, keycode, wanted_mask | (1 << mod_index), &mods_rtrn, &keysym_rtrn);
|
||||
|
||||
if (keysym_rtrn != keysym) {
|
||||
release_mask |= (1 << mod_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// finally check if the combination of pressed modifiers that we chose to ignore affects the keysym
|
||||
unsigned int mods_rtrn;
|
||||
KeySym keysym_rtrn;
|
||||
XkbTranslateKeyCode(m_xkb, keycode, wanted_mask | (release_check_mask & ~release_mask), &mods_rtrn, &keysym_rtrn);
|
||||
if (keysym_rtrn != keysym) {
|
||||
// oh well, release all the modifiers we don't want
|
||||
release_mask = release_check_mask;
|
||||
}
|
||||
|
||||
/* release all modifiers */
|
||||
SendModifier(&event, release_mask, KeyRelease);
|
||||
|
||||
SendModifier(&event, press_mask, KeyPress);
|
||||
|
||||
/* press and release key */
|
||||
event.keycode = keycode;
|
||||
@@ -647,10 +782,10 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym)
|
||||
SendEvent(&event, KeyRelease);
|
||||
|
||||
/* release the modifiers */
|
||||
SendModifier(&event, mask, KeyRelease);
|
||||
SendModifier(&event, press_mask, KeyRelease);
|
||||
|
||||
/* restore the old keyboard mask */
|
||||
SendModifier(&event, saved_mask, KeyPress);
|
||||
SendModifier(&event, release_mask, KeyPress);
|
||||
}
|
||||
|
||||
int AutoTypePlatformX11::MyErrorHandler(Display* my_dpy, XErrorEvent* event)
|
||||
@@ -686,4 +821,38 @@ int AutoTypePlatformX11::initialTimeout()
|
||||
return 500;
|
||||
}
|
||||
|
||||
bool AutoTypePlatformX11::raiseWindow(WId window)
|
||||
{
|
||||
if (m_atomNetActiveWindow == None) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XRaiseWindow(m_dpy, window);
|
||||
|
||||
XEvent event;
|
||||
event.xclient.type = ClientMessage;
|
||||
event.xclient.serial = 0;
|
||||
event.xclient.send_event = True;
|
||||
event.xclient.window = window;
|
||||
event.xclient.message_type = m_atomNetActiveWindow;
|
||||
event.xclient.format = 32;
|
||||
event.xclient.data.l[0] = 1; // FromApplication
|
||||
event.xclient.data.l[1] = QX11Info::appUserTime();
|
||||
QWidget* activeWindow = QApplication::activeWindow();
|
||||
if (activeWindow) {
|
||||
event.xclient.data.l[2] = activeWindow->internalWinId();
|
||||
}
|
||||
else {
|
||||
event.xclient.data.l[2] = 0;
|
||||
}
|
||||
event.xclient.data.l[3] = 0;
|
||||
event.xclient.data.l[4] = 0;
|
||||
XSendEvent(m_dpy, m_rootWindow, False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&event);
|
||||
XFlush(m_dpy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(keepassx-autotype-x11, AutoTypePlatformX11)
|
||||
|
||||
@@ -42,15 +42,17 @@ class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
|
||||
|
||||
public:
|
||||
AutoTypePlatformX11();
|
||||
bool isAvailable() Q_DECL_OVERRIDE;
|
||||
void unload() Q_DECL_OVERRIDE;
|
||||
QStringList windowTitles();
|
||||
WId activeWindow();
|
||||
QString activeWindowTitle();
|
||||
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
||||
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
|
||||
int platformEventFilter(void* event);
|
||||
int initialTimeout();
|
||||
AutoTypeExecutor* createExecutor();
|
||||
QStringList windowTitles() Q_DECL_OVERRIDE;
|
||||
WId activeWindow() Q_DECL_OVERRIDE;
|
||||
QString activeWindowTitle() Q_DECL_OVERRIDE;
|
||||
bool registerGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
void unregisterGlobalShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
|
||||
int platformEventFilter(void* event) Q_DECL_OVERRIDE;
|
||||
int initialTimeout() Q_DECL_OVERRIDE;
|
||||
bool raiseWindow(WId window) Q_DECL_OVERRIDE;
|
||||
AutoTypeExecutor* createExecutor() Q_DECL_OVERRIDE;
|
||||
|
||||
KeySym charToKeySym(const QChar& ch);
|
||||
KeySym keyToKeySym(Qt::Key key);
|
||||
@@ -71,12 +73,15 @@ private:
|
||||
void stopCatchXErrors();
|
||||
static int x11ErrorHandler(Display* display, XErrorEvent* error);
|
||||
|
||||
XkbDescPtr getKeyboard();
|
||||
void updateKeymap();
|
||||
bool isRemapKeycodeValid();
|
||||
int AddKeysym(KeySym keysym);
|
||||
void AddModifier(KeySym keysym);
|
||||
void SendEvent(XKeyEvent* event, int event_type);
|
||||
void SendModifier(XKeyEvent *event, unsigned int mask, int event_type);
|
||||
int GetKeycode(KeySym keysym, unsigned int *mask);
|
||||
bool keysymModifiers(KeySym keysym, int keycode, unsigned int *mask);
|
||||
|
||||
static int MyErrorHandler(Display* my_dpy, XErrorEvent* event);
|
||||
|
||||
@@ -87,6 +92,7 @@ private:
|
||||
Atom m_atomNetWmName;
|
||||
Atom m_atomString;
|
||||
Atom m_atomUtf8String;
|
||||
Atom m_atomNetActiveWindow;
|
||||
QSet<QString> m_classBlacklist;
|
||||
Qt::Key m_currentGlobalKey;
|
||||
Qt::KeyboardModifiers m_currentGlobalModifiers;
|
||||
@@ -106,8 +112,9 @@ private:
|
||||
int m_minKeycode;
|
||||
int m_maxKeycode;
|
||||
int m_keysymPerKeycode;
|
||||
/* dedicated 'special character' keycode */
|
||||
int m_specialCharacterKeycode;
|
||||
/* dedicated keycode for remapped keys */
|
||||
unsigned int m_remapKeycode;
|
||||
KeySym m_currentRemapKeysym;
|
||||
KeyCode m_modifier_keycode[N_MOD_INDICES];
|
||||
bool m_loaded;
|
||||
};
|
||||
@@ -117,8 +124,8 @@ class AutoTypeExecturorX11 : public AutoTypeExecutor
|
||||
public:
|
||||
explicit AutoTypeExecturorX11(AutoTypePlatformX11* platform);
|
||||
|
||||
void execChar(AutoTypeChar* action);
|
||||
void execKey(AutoTypeKey* action);
|
||||
void execChar(AutoTypeChar* action) Q_DECL_OVERRIDE;
|
||||
void execKey(AutoTypeKey* action) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
AutoTypePlatformX11* const m_platform;
|
||||
|
||||
@@ -11,7 +11,7 @@ set(autotype_X11_MOC
|
||||
qt4_wrap_cpp(autotype_X11_SOURCES ${autotype_X11_MOC})
|
||||
|
||||
add_library(keepassx-autotype-x11 MODULE ${autotype_X11_SOURCES})
|
||||
target_link_libraries(keepassx-autotype-x11 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${X11_X11_LIB} ${X11_XTest_LIB})
|
||||
target_link_libraries(keepassx-autotype-x11 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
|
||||
install(TARGETS keepassx-autotype-x11
|
||||
BUNDLE DESTINATION . COMPONENT Runtime
|
||||
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
/* config-keepassx.h. Generated by cmake from config-keepassx.h.cmake */
|
||||
|
||||
#ifndef KEEPASSX_CONFIG_H
|
||||
#define KEEPASSX_CONFIG_H
|
||||
#ifndef KEEPASSX_CONFIG_KEEPASSX_H
|
||||
#define KEEPASSX_CONFIG_KEEPASSX_H
|
||||
|
||||
#define KEEPASSX_VERSION "${KEEPASSX_VERSION}"
|
||||
|
||||
#define KEEPASSX_SOURCE_DIR "${CMAKE_SOURCE_DIR}"
|
||||
#define KEEPASSX_BINARY_DIR "${CMAKE_BINARY_DIR}"
|
||||
|
||||
#define KEEPASSX_PREFIX_DIR "${CMAKE_INSTALL_PREFIX}"
|
||||
#define KEEPASSX_PLUGIN_DIR "${PLUGIN_INSTALL_DIR}"
|
||||
#define KEEPASSX_DATA_DIR "${DATA_INSTALL_DIR}"
|
||||
|
||||
#cmakedefine HAVE_PR_SET_DUMPABLE 1
|
||||
#cmakedefine HAVE_RLIMIT_CORE 1
|
||||
#cmakedefine HAVE_PT_DENY_ATTACH 1
|
||||
|
||||
#endif // KEEPASSX_CONFIG_H
|
||||
#cmakedefine GCRYPT_HAS_SALSA20
|
||||
|
||||
#endif // KEEPASSX_CONFIG_KEEPASSX_H
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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++;
|
||||
}
|
||||
@@ -71,7 +71,8 @@ Config::Config(QObject* parent)
|
||||
userPath += "/keepassx/";
|
||||
#else
|
||||
userPath = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
|
||||
userPath += "/keepassx/";
|
||||
// storageLocation() appends the application name ("/keepassx") to the end
|
||||
userPath += "/";
|
||||
#endif
|
||||
|
||||
userPath += "keepassx2.ini";
|
||||
@@ -88,14 +89,23 @@ void Config::init(const QString& fileName)
|
||||
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
|
||||
|
||||
m_defaults.insert("RememberLastDatabases", true);
|
||||
m_defaults.insert("RememberLastKeyFiles", 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("UseGroupIconOnEntryCreation", false);
|
||||
m_defaults.insert("AutoTypeEntryTitleMatch", true);
|
||||
m_defaults.insert("security/clearclipboard", true);
|
||||
m_defaults.insert("security/clearclipboardtimeout", 10);
|
||||
m_defaults.insert("security/lockdatabaseidle", false);
|
||||
m_defaults.insert("security/lockdatabaseidlesec", 10);
|
||||
m_defaults.insert("security/passwordscleartext", false);
|
||||
m_defaults.insert("security/autotypeask", true);
|
||||
m_defaults.insert("GUI/Language", "system");
|
||||
m_defaults.insert("GUI/ShowTrayIcon", false);
|
||||
m_defaults.insert("GUI/MinimizeToTray", false);
|
||||
}
|
||||
|
||||
Config* Config::instance()
|
||||
@@ -107,7 +117,7 @@ Config* Config::instance()
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void Config::createConfigFromFile(QString file)
|
||||
void Config::createConfigFromFile(const QString& file)
|
||||
{
|
||||
Q_ASSERT(!m_instance);
|
||||
m_instance = new Config(file, qApp);
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
void set(const QString& key, const QVariant& value);
|
||||
|
||||
static Config* instance();
|
||||
static void createConfigFromFile(QString file);
|
||||
static void createConfigFromFile(const QString& file);
|
||||
static void createTempFileInstance();
|
||||
|
||||
private:
|
||||
|
||||
@@ -37,7 +37,7 @@ Database::Database()
|
||||
{
|
||||
m_data.cipher = KeePass2::CIPHER_AES;
|
||||
m_data.compressionAlgo = CompressionGZip;
|
||||
m_data.transformRounds = 50000;
|
||||
m_data.transformRounds = 100000;
|
||||
m_data.hasKey = false;
|
||||
|
||||
setRootGroup(new Group());
|
||||
@@ -188,32 +188,51 @@ void Database::setCompressionAlgo(Database::CompressionAlgorithm algo)
|
||||
m_data.compressionAlgo = algo;
|
||||
}
|
||||
|
||||
void Database::setTransformRounds(quint64 rounds)
|
||||
bool Database::setTransformRounds(quint64 rounds)
|
||||
{
|
||||
if (m_data.transformRounds != rounds) {
|
||||
quint64 oldRounds = m_data.transformRounds;
|
||||
|
||||
m_data.transformRounds = rounds;
|
||||
|
||||
if (m_data.hasKey) {
|
||||
setKey(m_data.key);
|
||||
if (!setKey(m_data.key)) {
|
||||
m_data.transformRounds = oldRounds;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed, bool updateChangedTime)
|
||||
bool Database::setKey(const CompositeKey& key, const QByteArray& transformSeed,
|
||||
bool updateChangedTime)
|
||||
{
|
||||
bool ok;
|
||||
QString errorString;
|
||||
|
||||
QByteArray transformedMasterKey =
|
||||
key.transform(transformSeed, transformRounds(), &ok, &errorString);
|
||||
if (!ok) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_data.key = key;
|
||||
m_data.transformSeed = transformSeed;
|
||||
m_data.transformedMasterKey = key.transform(transformSeed, transformRounds());
|
||||
m_data.transformedMasterKey = transformedMasterKey;
|
||||
m_data.hasKey = true;
|
||||
if (updateChangedTime) {
|
||||
m_metadata->setMasterKeyChanged(Tools::currentDateTimeUtc());
|
||||
}
|
||||
Q_EMIT modifiedImmediate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Database::setKey(const CompositeKey& key)
|
||||
bool Database::setKey(const CompositeKey& key)
|
||||
{
|
||||
setKey(key, randomGen()->randomArray(32));
|
||||
return setKey(key, randomGen()->randomArray(32));
|
||||
}
|
||||
|
||||
bool Database::hasKey() const
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
* Sets group as the root group and takes ownership of it.
|
||||
* Warning: Be careful when calling this method as it doesn't
|
||||
* emit any notifications so e.g. models aren't updated.
|
||||
* The caller is responsible for cleaning up the pervious
|
||||
* The caller is responsible for cleaning up the previous
|
||||
root group.
|
||||
*/
|
||||
void setRootGroup(Group* group);
|
||||
@@ -90,13 +90,14 @@ public:
|
||||
|
||||
void setCipher(const Uuid& cipher);
|
||||
void setCompressionAlgo(Database::CompressionAlgorithm algo);
|
||||
void setTransformRounds(quint64 rounds);
|
||||
void setKey(const CompositeKey& key, const QByteArray& transformSeed, bool updateChangedTime = true);
|
||||
bool setTransformRounds(quint64 rounds);
|
||||
bool setKey(const CompositeKey& key, const QByteArray& transformSeed,
|
||||
bool updateChangedTime = true);
|
||||
|
||||
/**
|
||||
* Sets the database key and generates a random transform seed.
|
||||
*/
|
||||
void setKey(const CompositeKey& key);
|
||||
bool setKey(const CompositeKey& key);
|
||||
bool hasKey() const;
|
||||
bool verifyKey(const CompositeKey& key) const;
|
||||
void recycleEntry(Entry* entry);
|
||||
|
||||
@@ -30,6 +30,7 @@ Entry::Entry()
|
||||
, m_attachments(new EntryAttachments(this))
|
||||
, m_autoTypeAssociations(new AutoTypeAssociations(this))
|
||||
, m_tmpHistoryItem(Q_NULLPTR)
|
||||
, m_modifiedSinceBegin(false)
|
||||
, m_updateTimeinfo(true)
|
||||
{
|
||||
m_data.iconNumber = DefaultIconNumber;
|
||||
@@ -113,13 +114,25 @@ QPixmap Entry::iconPixmap() const
|
||||
else {
|
||||
Q_ASSERT(database());
|
||||
|
||||
QPixmap pixmap;
|
||||
if (database() && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
|
||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||
if (database()) {
|
||||
return database()->metadata()->customIconPixmap(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QPixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
QPixmap Entry::iconScaledPixmap() const
|
||||
{
|
||||
if (m_data.customIcon.isNull()) {
|
||||
// built-in icons are 16x16 so don't need to be scaled
|
||||
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
Q_ASSERT(database());
|
||||
|
||||
return database()->metadata()->customIconScaledPixmap(m_data.customIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,8 +260,6 @@ void Entry::setIcon(int iconNumber)
|
||||
m_data.iconNumber = iconNumber;
|
||||
m_data.customIcon = Uuid();
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
|
||||
Q_EMIT modified();
|
||||
emitDataChanged();
|
||||
}
|
||||
@@ -262,8 +273,6 @@ void Entry::setIcon(const Uuid& uuid)
|
||||
m_data.customIcon = uuid;
|
||||
m_data.iconNumber = 0;
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
|
||||
Q_EMIT modified();
|
||||
emitDataChanged();
|
||||
}
|
||||
@@ -363,7 +372,6 @@ const QList<Entry*>& Entry::historyItems() const
|
||||
void Entry::addHistoryItem(Entry* entry)
|
||||
{
|
||||
Q_ASSERT(!entry->parent());
|
||||
Q_ASSERT(entry->uuid() == uuid());
|
||||
|
||||
m_history.append(entry);
|
||||
Q_EMIT modified();
|
||||
@@ -578,25 +586,6 @@ const Database* Entry::database() const
|
||||
}
|
||||
}
|
||||
|
||||
bool Entry::match(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
QStringList wordList = searchTerm.split(QRegExp("\\s"), QString::SkipEmptyParts);
|
||||
Q_FOREACH (const QString& word, wordList) {
|
||||
if (!wordMatch(word, caseSensitivity)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Entry::wordMatch(const QString& word, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
return title().contains(word, caseSensitivity) ||
|
||||
username().contains(word, caseSensitivity) ||
|
||||
url().contains(word, caseSensitivity) ||
|
||||
notes().contains(word, caseSensitivity);
|
||||
}
|
||||
|
||||
QString Entry::resolvePlaceholders(const QString& str) const
|
||||
{
|
||||
QString result = str;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <QImage>
|
||||
#include <QMap>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPointer>
|
||||
#include <QSet>
|
||||
#include <QUrl>
|
||||
@@ -61,6 +60,7 @@ public:
|
||||
Uuid uuid() const;
|
||||
QImage icon() const;
|
||||
QPixmap iconPixmap() const;
|
||||
QPixmap iconScaledPixmap() const;
|
||||
int iconNumber() const;
|
||||
Uuid iconUuid() const;
|
||||
QColor foregroundColor() const;
|
||||
@@ -141,7 +141,6 @@ public:
|
||||
void setGroup(Group* group);
|
||||
|
||||
void setUpdateTimeinfo(bool value);
|
||||
bool match(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity);
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
@@ -157,7 +156,6 @@ private Q_SLOTS:
|
||||
void updateModifiedSinceBegin();
|
||||
|
||||
private:
|
||||
bool wordMatch(const QString& word, Qt::CaseSensitivity caseSensitivity);
|
||||
const Database* database() const;
|
||||
template <class T> bool set(T& property, const T& value);
|
||||
|
||||
@@ -171,7 +169,6 @@ private:
|
||||
Entry* m_tmpHistoryItem;
|
||||
bool m_modifiedSinceBegin;
|
||||
QPointer<Group> m_group;
|
||||
mutable QPixmapCache::Key m_pixmapCacheKey;
|
||||
bool m_updateTimeinfo;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ QList<QString> EntryAttachments::keys() const
|
||||
return m_attachments.keys();
|
||||
}
|
||||
|
||||
bool EntryAttachments::hasKey(const QString& key) const
|
||||
{
|
||||
return m_attachments.keys().contains(key);
|
||||
}
|
||||
|
||||
QList<QByteArray> EntryAttachments::values() const
|
||||
{
|
||||
return m_attachments.values();
|
||||
|
||||
@@ -30,6 +30,7 @@ class EntryAttachments : public QObject
|
||||
public:
|
||||
explicit EntryAttachments(QObject* parent = Q_NULLPTR);
|
||||
QList<QString> keys() const;
|
||||
bool hasKey(const QString& key) const;
|
||||
QList<QByteArray> values() const;
|
||||
QByteArray value(const QString& key) const;
|
||||
void set(const QString& key, const QByteArray& value);
|
||||
|
||||
@@ -36,6 +36,11 @@ QList<QString> EntryAttributes::keys() const
|
||||
return m_attributes.keys();
|
||||
}
|
||||
|
||||
bool EntryAttributes::hasKey(const QString& key) const
|
||||
{
|
||||
return m_attributes.keys().contains(key);
|
||||
}
|
||||
|
||||
QList<QString> EntryAttributes::customKeys()
|
||||
{
|
||||
QList<QString> customKeys;
|
||||
|
||||
@@ -32,6 +32,7 @@ class EntryAttributes : public QObject
|
||||
public:
|
||||
explicit EntryAttributes(QObject* parent = Q_NULLPTR);
|
||||
QList<QString> keys() const;
|
||||
bool hasKey(const QString& key) const;
|
||||
QList<QString> customKeys();
|
||||
QString value(const QString& key) const;
|
||||
bool isProtected(const QString& key) const;
|
||||
|
||||
65
src/core/EntrySearcher.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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 "EntrySearcher.h"
|
||||
|
||||
#include "core/Group.h"
|
||||
|
||||
QList<Entry*> EntrySearcher::search(const QString &searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
if (!group->resolveSearchingEnabled()) {
|
||||
return QList<Entry*>();
|
||||
}
|
||||
|
||||
return searchEntries(searchTerm, group, caseSensitivity);
|
||||
}
|
||||
|
||||
QList<Entry*> EntrySearcher::searchEntries(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
QList<Entry*> searchResult;
|
||||
|
||||
Q_FOREACH (Entry* entry, group->entries()) {
|
||||
searchResult.append(matchEntry(searchTerm, entry, caseSensitivity));
|
||||
}
|
||||
Q_FOREACH (Group* childGroup, group->children()) {
|
||||
if (childGroup->searchingEnabled() != Group::Disable) {
|
||||
searchResult.append(searchEntries(searchTerm, childGroup, caseSensitivity));
|
||||
}
|
||||
}
|
||||
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
QList<Entry*> EntrySearcher::matchEntry(const QString& searchTerm, Entry* entry, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
QStringList wordList = searchTerm.split(QRegExp("\\s"), QString::SkipEmptyParts);
|
||||
Q_FOREACH (const QString& word, wordList) {
|
||||
if (!wordMatch(word, entry, caseSensitivity)) {
|
||||
return QList<Entry*>();
|
||||
}
|
||||
}
|
||||
|
||||
return QList<Entry*>() << entry;
|
||||
}
|
||||
|
||||
bool EntrySearcher::wordMatch(const QString& word, Entry* entry, Qt::CaseSensitivity caseSensitivity)
|
||||
{
|
||||
return entry->title().contains(word, caseSensitivity) ||
|
||||
entry->username().contains(word, caseSensitivity) ||
|
||||
entry->url().contains(word, caseSensitivity) ||
|
||||
entry->notes().contains(word, caseSensitivity);
|
||||
}
|
||||
37
src/core/EntrySearcher.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Florian 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/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_ENTRYSEARCHER_H
|
||||
#define KEEPASSX_ENTRYSEARCHER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
class Group;
|
||||
class Entry;
|
||||
|
||||
class EntrySearcher
|
||||
{
|
||||
public:
|
||||
QList<Entry*> search(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity);
|
||||
private:
|
||||
QList<Entry*> searchEntries(const QString& searchTerm, const Group* group, Qt::CaseSensitivity caseSensitivity);
|
||||
QList<Entry*> matchEntry(const QString& searchTerm, Entry* entry, Qt::CaseSensitivity caseSensitivity);
|
||||
bool wordMatch(const QString &word, Entry *entry, Qt::CaseSensitivity caseSensitivity);
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ENTRYSEARCHER_H
|
||||
14
src/core/Exporter.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef KEEPASSX_EXPORTER_H
|
||||
#define KEEPASSX_EXPORTER_H
|
||||
|
||||
class Database;
|
||||
class Group;
|
||||
|
||||
class Exporter
|
||||
{
|
||||
public:
|
||||
virtual Database* exportGroup(Group* group) = 0;
|
||||
virtual ~Exporter() {}
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_EXPORTER_H
|
||||
@@ -49,13 +49,20 @@ QString FilePath::pluginPath(const QString& name)
|
||||
|
||||
pluginPaths << QCoreApplication::applicationDirPath();
|
||||
|
||||
QString systemPluginDir = KEEPASSX_PLUGIN_DIR;
|
||||
if (systemPluginDir != ".") {
|
||||
if (!QDir(systemPluginDir).isAbsolute()) {
|
||||
systemPluginDir = QCoreApplication::applicationDirPath() + "/../" + systemPluginDir;
|
||||
systemPluginDir = QDir(systemPluginDir).canonicalPath();
|
||||
QString configuredPluginDir = KEEPASSX_PLUGIN_DIR;
|
||||
if (configuredPluginDir != ".") {
|
||||
if (QDir(configuredPluginDir).isAbsolute()) {
|
||||
pluginPaths << configuredPluginDir;
|
||||
}
|
||||
else {
|
||||
QString relativePluginDir = QString("%1/../%2")
|
||||
.arg(QCoreApplication::applicationDirPath(), configuredPluginDir);
|
||||
pluginPaths << QDir(relativePluginDir).canonicalPath();
|
||||
|
||||
QString absolutePluginDir = QString("%1/%2")
|
||||
.arg(KEEPASSX_PREFIX_DIR, configuredPluginDir);
|
||||
pluginPaths << QDir(absolutePluginDir).canonicalPath();
|
||||
}
|
||||
pluginPaths << systemPluginDir;
|
||||
}
|
||||
|
||||
QStringList dirFilter;
|
||||
@@ -106,7 +113,7 @@ QIcon FilePath::icon(const QString& category, const QString& name, bool fromThem
|
||||
icon.addFile(filename, QSize(size, size));
|
||||
}
|
||||
}
|
||||
filename = QString("%1/icons/application/scalable/%3.svgz").arg(m_dataPath, combinedName);
|
||||
filename = QString("%1/icons/application/scalable/%2.svgz").arg(m_dataPath, combinedName);
|
||||
if (QFile::exists(filename)) {
|
||||
icon.addFile(filename);
|
||||
}
|
||||
@@ -117,8 +124,57 @@ QIcon FilePath::icon(const QString& category, const QString& name, bool fromThem
|
||||
return icon;
|
||||
}
|
||||
|
||||
QIcon FilePath::onOffIcon(const QString& category, const QString& name)
|
||||
{
|
||||
QString combinedName = category + "/" + name;
|
||||
QString cacheName = "onoff/" + combinedName;
|
||||
|
||||
QIcon icon = m_iconCache.value(cacheName);
|
||||
|
||||
if (!icon.isNull()) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
QIcon::State state;
|
||||
QString stateName;
|
||||
|
||||
if (i == 0) {
|
||||
state = QIcon::Off;
|
||||
stateName = "off";
|
||||
}
|
||||
else {
|
||||
state = QIcon::On;
|
||||
stateName = "on";
|
||||
}
|
||||
|
||||
QList<int> pngSizes;
|
||||
pngSizes << 16 << 22 << 24 << 32 << 48 << 64 << 128;
|
||||
QString filename;
|
||||
Q_FOREACH (int size, pngSizes) {
|
||||
filename = QString("%1/icons/application/%2x%2/%3-%4.png").arg(m_dataPath, QString::number(size),
|
||||
combinedName, stateName);
|
||||
if (QFile::exists(filename)) {
|
||||
icon.addFile(filename, QSize(size, size), QIcon::Normal, state);
|
||||
}
|
||||
}
|
||||
filename = QString("%1/icons/application/scalable/%2-%3.svgz").arg(m_dataPath, combinedName, stateName);
|
||||
if (QFile::exists(filename)) {
|
||||
icon.addFile(filename, QSize(), QIcon::Normal, state);
|
||||
}
|
||||
}
|
||||
|
||||
m_iconCache.insert(cacheName, icon);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
FilePath::FilePath()
|
||||
{
|
||||
const QString appDirPath = QCoreApplication::applicationDirPath();
|
||||
bool isDataDirAbsolute = QDir::isAbsolutePath(KEEPASSX_DATA_DIR);
|
||||
Q_UNUSED(isDataDirAbsolute);
|
||||
|
||||
if (false) {
|
||||
}
|
||||
#ifdef QT_DEBUG
|
||||
@@ -126,15 +182,19 @@ FilePath::FilePath()
|
||||
}
|
||||
#endif
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
|
||||
else if (testSetDir(QCoreApplication::applicationDirPath() + "/../share/keepassx")) {
|
||||
else if (isDataDirAbsolute && testSetDir(KEEPASSX_DATA_DIR)) {
|
||||
}
|
||||
else if (!isDataDirAbsolute && testSetDir(QString("%1/../%2").arg(appDirPath, KEEPASSX_DATA_DIR))) {
|
||||
}
|
||||
else if (!isDataDirAbsolute && testSetDir(QString("%1/%2").arg(KEEPASSX_PREFIX_DIR, KEEPASSX_DATA_DIR))) {
|
||||
}
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
else if (testSetDir(QCoreApplication::applicationDirPath() + "/../Resources")) {
|
||||
else if (testSetDir(appDirPath + "/../Resources")) {
|
||||
}
|
||||
#endif
|
||||
#ifdef Q_OS_WIN
|
||||
else if (testSetDir(QCoreApplication::applicationDirPath() + "/share")) {
|
||||
else if (testSetDir(appDirPath + "/share")) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
QString pluginPath(const QString& name);
|
||||
QIcon applicationIcon();
|
||||
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
|
||||
QIcon onOffIcon(const QString& category, const QString& name);
|
||||
|
||||
static FilePath* instance();
|
||||
|
||||
|
||||
@@ -134,13 +134,30 @@ QPixmap Group::iconPixmap() const
|
||||
else {
|
||||
Q_ASSERT(m_db);
|
||||
|
||||
QPixmap pixmap;
|
||||
if (m_db && !QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(m_db->metadata()->customIcon(m_data.customIcon));
|
||||
m_pixmapCacheKey = QPixmapCache::insert(pixmap);
|
||||
if (m_db) {
|
||||
return m_db->metadata()->customIconPixmap(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QPixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
QPixmap Group::iconScaledPixmap() const
|
||||
{
|
||||
if (m_data.customIcon.isNull()) {
|
||||
// built-in icons are 16x16 so don't need to be scaled
|
||||
return databaseIcons()->iconPixmap(m_data.iconNumber);
|
||||
}
|
||||
else {
|
||||
Q_ASSERT(m_db);
|
||||
|
||||
if (m_db) {
|
||||
return m_db->metadata()->customIconScaledPixmap(m_data.customIcon);
|
||||
}
|
||||
else {
|
||||
return QPixmap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +231,6 @@ void Group::setIcon(int iconNumber)
|
||||
m_data.iconNumber = iconNumber;
|
||||
m_data.customIcon = Uuid();
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
|
||||
updateTimeinfo();
|
||||
Q_EMIT modified();
|
||||
Q_EMIT dataChanged(this);
|
||||
@@ -230,8 +245,6 @@ void Group::setIcon(const Uuid& uuid)
|
||||
m_data.customIcon = uuid;
|
||||
m_data.iconNumber = 0;
|
||||
|
||||
m_pixmapCacheKey = QPixmapCache::Key();
|
||||
|
||||
updateTimeinfo();
|
||||
Q_EMIT modified();
|
||||
Q_EMIT dataChanged(this);
|
||||
@@ -248,9 +261,7 @@ void Group::setExpanded(bool expanded)
|
||||
if (m_data.isExpanded != expanded) {
|
||||
m_data.isExpanded = expanded;
|
||||
updateTimeinfo();
|
||||
if (config()->get("ModifiedOnExpandedStateChanges").toBool()) {
|
||||
Q_EMIT modified();
|
||||
}
|
||||
Q_EMIT modified();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,6 +447,20 @@ QList<const Group*> Group::groupsRecursive(bool includeSelf) const
|
||||
groupList.append(this);
|
||||
}
|
||||
|
||||
Q_FOREACH (const Group* group, m_children) {
|
||||
groupList.append(group->groupsRecursive(true));
|
||||
}
|
||||
|
||||
return groupList;
|
||||
}
|
||||
|
||||
QList<Group*> Group::groupsRecursive(bool includeSelf)
|
||||
{
|
||||
QList<Group*> groupList;
|
||||
if (includeSelf) {
|
||||
groupList.append(this);
|
||||
}
|
||||
|
||||
Q_FOREACH (Group* group, m_children) {
|
||||
groupList.append(group->groupsRecursive(true));
|
||||
}
|
||||
@@ -479,7 +504,7 @@ Group* Group::clone(Entry::CloneFlags entryFlags) const
|
||||
}
|
||||
|
||||
Q_FOREACH (Group* groupChild, children()) {
|
||||
Group* clonedGroupChild = groupChild->clone();
|
||||
Group* clonedGroupChild = groupChild->clone(entryFlags);
|
||||
clonedGroupChild->setParent(clonedGroup);
|
||||
}
|
||||
|
||||
@@ -500,22 +525,6 @@ void Group::copyDataFrom(const Group* other)
|
||||
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);
|
||||
@@ -612,24 +621,7 @@ void Group::recCreateDelObjects()
|
||||
}
|
||||
}
|
||||
|
||||
QList<Entry*> Group::search(const QString& searchTerm, Qt::CaseSensitivity caseSensitivity,
|
||||
bool resolveInherit)
|
||||
{
|
||||
QList<Entry*> searchResult;
|
||||
if (includeInSearch(resolveInherit)) {
|
||||
Q_FOREACH (Entry* entry, m_entries) {
|
||||
if (entry->match(searchTerm, caseSensitivity)) {
|
||||
searchResult.append(entry);
|
||||
}
|
||||
}
|
||||
Q_FOREACH (Group* group, m_children) {
|
||||
searchResult.append(group->search(searchTerm, caseSensitivity, false));
|
||||
}
|
||||
}
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
bool Group::includeInSearch(bool resolveInherit)
|
||||
bool Group::resolveSearchingEnabled() const
|
||||
{
|
||||
switch (m_data.searchingEnabled) {
|
||||
case Inherit:
|
||||
@@ -637,12 +629,27 @@ bool Group::includeInSearch(bool resolveInherit)
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (resolveInherit) {
|
||||
return m_parent->includeInSearch(true);
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
return m_parent->resolveSearchingEnabled();
|
||||
}
|
||||
case Enable:
|
||||
return true;
|
||||
case Disable:
|
||||
return false;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Group::resolveAutoTypeEnabled() const
|
||||
{
|
||||
switch (m_data.autoTypeEnabled) {
|
||||
case Inherit:
|
||||
if (!m_parent) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return m_parent->resolveAutoTypeEnabled();
|
||||
}
|
||||
case Enable:
|
||||
return true;
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
QString notes() const;
|
||||
QImage icon() const;
|
||||
QPixmap iconPixmap() const;
|
||||
QPixmap iconScaledPixmap() const;
|
||||
int iconNumber() const;
|
||||
Uuid iconUuid() const;
|
||||
TimeInfo timeInfo() const;
|
||||
@@ -65,6 +66,8 @@ public:
|
||||
QString defaultAutoTypeSequence() const;
|
||||
Group::TriState autoTypeEnabled() const;
|
||||
Group::TriState searchingEnabled() const;
|
||||
bool resolveSearchingEnabled() const;
|
||||
bool resolveAutoTypeEnabled() const;
|
||||
Entry* lastTopVisibleEntry() const;
|
||||
bool isExpired() const;
|
||||
|
||||
@@ -99,6 +102,7 @@ public:
|
||||
const QList<Entry*>& entries() const;
|
||||
QList<Entry*> entriesRecursive(bool includeHistoryItems = false) const;
|
||||
QList<const Group*> groupsRecursive(bool includeSelf) const;
|
||||
QList<Group*> groupsRecursive(bool includeSelf);
|
||||
QSet<Uuid> customIconsRecursive() const;
|
||||
/**
|
||||
* Creates a duplicate of this group including all child entries and groups.
|
||||
@@ -109,10 +113,6 @@ public:
|
||||
*/
|
||||
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);
|
||||
|
||||
Q_SIGNALS:
|
||||
void dataChanged(Group* group);
|
||||
@@ -147,7 +147,6 @@ private:
|
||||
void cleanupParent();
|
||||
void recCreateDelObjects();
|
||||
void updateTimeinfo();
|
||||
bool includeInSearch(bool resolveInherit);
|
||||
|
||||
QPointer<Database> m_db;
|
||||
Uuid m_uuid;
|
||||
@@ -157,7 +156,6 @@ private:
|
||||
QList<Entry*> m_entries;
|
||||
|
||||
QPointer<Group> m_parent;
|
||||
mutable QPixmapCache::Key m_pixmapCacheKey;
|
||||
|
||||
bool m_updateTimeinfo;
|
||||
|
||||
|
||||
80
src/core/InactivityTimer.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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/>.
|
||||
*/
|
||||
|
||||
#include "InactivityTimer.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QTimer>
|
||||
|
||||
InactivityTimer::InactivityTimer(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_timer(new QTimer(this))
|
||||
, m_active(false)
|
||||
{
|
||||
m_timer->setSingleShot(true);
|
||||
connect(m_timer, SIGNAL(timeout()), SLOT(timeout()));
|
||||
}
|
||||
|
||||
void InactivityTimer::setInactivityTimeout(int inactivityTimeout)
|
||||
{
|
||||
Q_ASSERT(inactivityTimeout > 0);
|
||||
|
||||
m_timer->setInterval(inactivityTimeout);
|
||||
}
|
||||
|
||||
void InactivityTimer::activate()
|
||||
{
|
||||
if (!m_active) {
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
m_active = true;
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
void InactivityTimer::deactivate()
|
||||
{
|
||||
qApp->removeEventFilter(this);
|
||||
m_active = false;
|
||||
m_timer->stop();
|
||||
}
|
||||
|
||||
bool InactivityTimer::eventFilter(QObject* watched, QEvent* event)
|
||||
{
|
||||
const QEvent::Type type = event->type();
|
||||
|
||||
if ( (type >= QEvent::MouseButtonPress && type <= QEvent::KeyRelease)
|
||||
|| (type >= QEvent::HoverEnter && type <= QEvent::HoverMove)
|
||||
|| (type == QEvent::Wheel) ) {
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
void InactivityTimer::timeout()
|
||||
{
|
||||
// make sure we don't emit the signal a second time while it's still processed
|
||||
if (!m_emitMutx.tryLock()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_active && !m_timer->isActive()) {
|
||||
Q_EMIT inactivityDetected();
|
||||
}
|
||||
|
||||
m_emitMutx.unlock();
|
||||
}
|
||||
53
src/core/InactivityTimer.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_INACTIVITYTIMER_H
|
||||
#define KEEPASSX_INACTIVITYTIMER_H
|
||||
|
||||
#include <QMutex>
|
||||
#include <QObject>
|
||||
|
||||
#include "core/Global.h"
|
||||
|
||||
class QTimer;
|
||||
|
||||
class InactivityTimer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit InactivityTimer(QObject* parent = Q_NULLPTR);
|
||||
void setInactivityTimeout(int inactivityTimeout);
|
||||
void activate();
|
||||
void deactivate();
|
||||
|
||||
Q_SIGNALS:
|
||||
void inactivityDetected();
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* watched, QEvent* event);
|
||||
|
||||
private Q_SLOTS:
|
||||
void timeout();
|
||||
|
||||
private:
|
||||
QTimer* m_timer;
|
||||
bool m_active;
|
||||
QMutex m_emitMutx;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_INACTIVITYTIMER_H
|
||||
@@ -167,6 +167,43 @@ QImage Metadata::customIcon(const Uuid& uuid) const
|
||||
return m_customIcons.value(uuid);
|
||||
}
|
||||
|
||||
QPixmap Metadata::customIconPixmap(const Uuid& uuid) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
||||
if (!m_customIcons.contains(uuid)) {
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmapCache::Key& cacheKey = m_customIconCacheKeys[uuid];
|
||||
|
||||
if (!QPixmapCache::find(cacheKey, &pixmap)) {
|
||||
pixmap = QPixmap::fromImage(m_customIcons.value(uuid));
|
||||
cacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmap Metadata::customIconScaledPixmap(const Uuid& uuid) const
|
||||
{
|
||||
QPixmap pixmap;
|
||||
|
||||
if (!m_customIcons.contains(uuid)) {
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPixmapCache::Key& cacheKey = m_customIconScaledCacheKeys[uuid];
|
||||
|
||||
if (!QPixmapCache::find(cacheKey, &pixmap)) {
|
||||
QImage image = m_customIcons.value(uuid).scaled(16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
pixmap = QPixmap::fromImage(image);
|
||||
cacheKey = QPixmapCache::insert(pixmap);
|
||||
}
|
||||
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
bool Metadata::containsCustomIcon(const Uuid& uuid) const
|
||||
{
|
||||
return m_customIcons.contains(uuid);
|
||||
@@ -177,6 +214,17 @@ QHash<Uuid, QImage> Metadata::customIcons() const
|
||||
return m_customIcons;
|
||||
}
|
||||
|
||||
QHash<Uuid, QPixmap> Metadata::customIconsScaledPixmaps() const
|
||||
{
|
||||
QHash<Uuid, QPixmap> result;
|
||||
|
||||
Q_FOREACH (const Uuid& uuid, m_customIconsOrder) {
|
||||
result.insert(uuid, customIconScaledPixmap(uuid));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<Uuid> Metadata::customIconsOrder() const
|
||||
{
|
||||
return m_customIconsOrder;
|
||||
@@ -338,17 +386,40 @@ void Metadata::addCustomIcon(const Uuid& uuid, const QImage& icon)
|
||||
Q_ASSERT(!m_customIcons.contains(uuid));
|
||||
|
||||
m_customIcons.insert(uuid, icon);
|
||||
// reset cache in case there is also an icon with that uuid
|
||||
m_customIconCacheKeys[uuid] = QPixmapCache::Key();
|
||||
m_customIconScaledCacheKeys[uuid] = QPixmapCache::Key();
|
||||
m_customIconsOrder.append(uuid);
|
||||
Q_ASSERT(m_customIcons.count() == m_customIconsOrder.count());
|
||||
Q_EMIT modified();
|
||||
}
|
||||
|
||||
void Metadata::addCustomIconScaled(const Uuid& uuid, const QImage& icon)
|
||||
{
|
||||
QImage iconScaled;
|
||||
|
||||
// scale down to 128x128 if icon is larger
|
||||
if (icon.width() > 128 || icon.height() > 128) {
|
||||
iconScaled = icon.scaled(QSize(128, 128), Qt::KeepAspectRatio,
|
||||
Qt::SmoothTransformation);
|
||||
}
|
||||
else {
|
||||
iconScaled = icon;
|
||||
}
|
||||
|
||||
addCustomIcon(uuid, iconScaled);
|
||||
}
|
||||
|
||||
void Metadata::removeCustomIcon(const Uuid& uuid)
|
||||
{
|
||||
Q_ASSERT(!uuid.isNull());
|
||||
Q_ASSERT(m_customIcons.contains(uuid));
|
||||
|
||||
m_customIcons.remove(uuid);
|
||||
QPixmapCache::remove(m_customIconCacheKeys.value(uuid));
|
||||
m_customIconCacheKeys.remove(uuid);
|
||||
QPixmapCache::remove(m_customIconScaledCacheKeys.value(uuid));
|
||||
m_customIconScaledCacheKeys.remove(uuid);
|
||||
m_customIconsOrder.removeAll(uuid);
|
||||
Q_ASSERT(m_customIcons.count() == m_customIconsOrder.count());
|
||||
Q_EMIT modified();
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include <QDateTime>
|
||||
#include <QHash>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QPixmapCache>
|
||||
#include <QPointer>
|
||||
|
||||
#include "core/Global.h"
|
||||
@@ -78,10 +80,13 @@ public:
|
||||
bool protectNotes() const;
|
||||
// bool autoEnableVisualHiding() const;
|
||||
QImage customIcon(const Uuid& uuid) const;
|
||||
QPixmap customIconPixmap(const Uuid& uuid) const;
|
||||
QPixmap customIconScaledPixmap(const Uuid& uuid) const;
|
||||
bool containsCustomIcon(const Uuid& uuid) const;
|
||||
QHash<Uuid, QImage> customIcons() const;
|
||||
QList<Uuid> customIconsOrder() const;
|
||||
bool recycleBinEnabled() const;
|
||||
QHash<Uuid, QPixmap> customIconsScaledPixmaps() const;
|
||||
Group* recycleBin();
|
||||
const Group* recycleBin() const;
|
||||
QDateTime recycleBinChanged() const;
|
||||
@@ -115,6 +120,7 @@ public:
|
||||
void setProtectNotes(bool value);
|
||||
// void setAutoEnableVisualHiding(bool value);
|
||||
void addCustomIcon(const Uuid& uuid, const QImage& icon);
|
||||
void addCustomIconScaled(const Uuid& uuid, const QImage& icon);
|
||||
void removeCustomIcon(const Uuid& uuid);
|
||||
void copyCustomIcons(const QSet<Uuid>& iconList, const Metadata* otherMetadata);
|
||||
void setRecycleBinEnabled(bool value);
|
||||
@@ -152,6 +158,8 @@ private:
|
||||
MetadataData m_data;
|
||||
|
||||
QHash<Uuid, QImage> m_customIcons;
|
||||
mutable QHash<Uuid, QPixmapCache::Key> m_customIconCacheKeys;
|
||||
mutable QHash<Uuid, QPixmapCache::Key> m_customIconScaledCacheKeys;
|
||||
QList<Uuid> m_customIconsOrder;
|
||||
|
||||
QPointer<Group> m_recycleBin;
|
||||
|
||||
@@ -19,15 +19,33 @@
|
||||
|
||||
#include "crypto/Random.h"
|
||||
|
||||
PasswordGenerator* PasswordGenerator::m_instance = Q_NULLPTR;
|
||||
|
||||
QString PasswordGenerator::generatePassword(int length,
|
||||
const PasswordGenerator::CharClasses& classes,
|
||||
const PasswordGenerator::GeneratorFlags& flags)
|
||||
PasswordGenerator::PasswordGenerator()
|
||||
: m_length(0)
|
||||
, m_classes(0)
|
||||
, m_flags(0)
|
||||
{
|
||||
Q_ASSERT(isValidCombination(length, classes, flags));
|
||||
}
|
||||
|
||||
QVector<PasswordGroup> groups = passwordGroups(classes, flags);
|
||||
void PasswordGenerator::setLength(int length)
|
||||
{
|
||||
m_length = length;
|
||||
}
|
||||
|
||||
void PasswordGenerator::setCharClasses(const CharClasses& classes)
|
||||
{
|
||||
m_classes = classes;
|
||||
}
|
||||
|
||||
void PasswordGenerator::setFlags(const GeneratorFlags& flags)
|
||||
{
|
||||
m_flags = flags;
|
||||
}
|
||||
|
||||
QString PasswordGenerator::generatePassword() const
|
||||
{
|
||||
Q_ASSERT(isValid());
|
||||
|
||||
QVector<PasswordGroup> groups = passwordGroups();
|
||||
|
||||
QVector<QChar> passwordChars;
|
||||
Q_FOREACH (const PasswordGroup& group, groups) {
|
||||
@@ -38,14 +56,14 @@ QString PasswordGenerator::generatePassword(int length,
|
||||
|
||||
QString password;
|
||||
|
||||
if (flags & CharFromEveryGroup) {
|
||||
if (m_flags & CharFromEveryGroup) {
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
int pos = randomGen()->randomUInt(groups[i].size());
|
||||
|
||||
password.append(groups[i][pos]);
|
||||
}
|
||||
|
||||
for (int i = groups.size(); i < length; i++) {
|
||||
for (int i = groups.size(); i < m_length; i++) {
|
||||
int pos = randomGen()->randomUInt(passwordChars.size());
|
||||
|
||||
password.append(passwordChars[pos]);
|
||||
@@ -61,7 +79,7 @@ QString PasswordGenerator::generatePassword(int length,
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (int i = 0; i < m_length; i++) {
|
||||
int pos = randomGen()->randomUInt(passwordChars.size());
|
||||
|
||||
password.append(passwordChars[pos]);
|
||||
@@ -71,34 +89,31 @@ QString PasswordGenerator::generatePassword(int length,
|
||||
return password;
|
||||
}
|
||||
|
||||
bool PasswordGenerator::isValidCombination(int length,
|
||||
const PasswordGenerator::CharClasses& classes,
|
||||
const PasswordGenerator::GeneratorFlags& flags)
|
||||
bool PasswordGenerator::isValid() const
|
||||
{
|
||||
if (classes == 0) {
|
||||
if (m_classes == 0) {
|
||||
return false;
|
||||
}
|
||||
else if (length == 0) {
|
||||
else if (m_length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((flags & CharFromEveryGroup) && (length < numCharClasses(classes))) {
|
||||
if ((m_flags & CharFromEveryGroup) && (m_length < numCharClasses())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<PasswordGroup> PasswordGenerator::passwordGroups(const PasswordGenerator::CharClasses& classes,
|
||||
const PasswordGenerator::GeneratorFlags& flags)
|
||||
QVector<PasswordGroup> PasswordGenerator::passwordGroups() const
|
||||
{
|
||||
QVector<PasswordGroup> passwordGroups;
|
||||
|
||||
if (classes & LowerLetters) {
|
||||
if (m_classes & LowerLetters) {
|
||||
PasswordGroup group;
|
||||
|
||||
for (int i = 97; i < (97 + 26); i++) {
|
||||
if ((flags & ExcludeLookAlike) && (i == 108)) { // "l"
|
||||
if ((m_flags & ExcludeLookAlike) && (i == 108)) { // "l"
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -107,11 +122,11 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups(const PasswordGenerator
|
||||
|
||||
passwordGroups.append(group);
|
||||
}
|
||||
if (classes & UpperLetters) {
|
||||
if (m_classes & UpperLetters) {
|
||||
PasswordGroup group;
|
||||
|
||||
for (int i = 65; i < (65 + 26); i++) {
|
||||
if ((flags & ExcludeLookAlike) && (i == 73 || i == 79)) { // "I" and "O"
|
||||
if ((m_flags & ExcludeLookAlike) && (i == 73 || i == 79)) { // "I" and "O"
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -120,11 +135,11 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups(const PasswordGenerator
|
||||
|
||||
passwordGroups.append(group);
|
||||
}
|
||||
if (classes & Numbers) {
|
||||
if (m_classes & Numbers) {
|
||||
PasswordGroup group;
|
||||
|
||||
for (int i = 48; i < (48 + 10); i++) {
|
||||
if ((flags & ExcludeLookAlike) && (i == 48 || i == 49)) { // "0" and "1"
|
||||
if ((m_flags & ExcludeLookAlike) && (i == 48 || i == 49)) { // "0" and "1"
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -133,7 +148,7 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups(const PasswordGenerator
|
||||
|
||||
passwordGroups.append(group);
|
||||
}
|
||||
if (classes & SpecialCharacters) {
|
||||
if (m_classes & SpecialCharacters) {
|
||||
PasswordGroup group;
|
||||
|
||||
for (int i = 33; i <= 47; i++) {
|
||||
@@ -149,7 +164,7 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups(const PasswordGenerator
|
||||
}
|
||||
|
||||
for (int i = 123; i <= 126; i++) {
|
||||
if ((flags & ExcludeLookAlike) && (i == 124)) { // "|"
|
||||
if ((m_flags & ExcludeLookAlike) && (i == 124)) { // "|"
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -162,35 +177,22 @@ QVector<PasswordGroup> PasswordGenerator::passwordGroups(const PasswordGenerator
|
||||
return passwordGroups;
|
||||
}
|
||||
|
||||
int PasswordGenerator::numCharClasses(const PasswordGenerator::CharClasses& classes)
|
||||
int PasswordGenerator::numCharClasses() const
|
||||
{
|
||||
int numClasses = 0;
|
||||
|
||||
if (classes & LowerLetters) {
|
||||
if (m_classes & LowerLetters) {
|
||||
numClasses++;
|
||||
}
|
||||
if (classes & UpperLetters) {
|
||||
if (m_classes & UpperLetters) {
|
||||
numClasses++;
|
||||
}
|
||||
if (classes & Numbers) {
|
||||
if (m_classes & Numbers) {
|
||||
numClasses++;
|
||||
}
|
||||
if (classes & SpecialCharacters) {
|
||||
if (m_classes & SpecialCharacters) {
|
||||
numClasses++;
|
||||
}
|
||||
|
||||
return numClasses;
|
||||
}
|
||||
|
||||
PasswordGenerator* PasswordGenerator::instance()
|
||||
{
|
||||
if (!m_instance) {
|
||||
m_instance = new PasswordGenerator();
|
||||
}
|
||||
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
PasswordGenerator::PasswordGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,29 +45,28 @@ public:
|
||||
};
|
||||
Q_DECLARE_FLAGS(GeneratorFlags, GeneratorFlag)
|
||||
|
||||
QString generatePassword(int length, const PasswordGenerator::CharClasses& classes,
|
||||
const PasswordGenerator::GeneratorFlags& flags);
|
||||
bool isValidCombination(int length, const PasswordGenerator::CharClasses& classes,
|
||||
const PasswordGenerator::GeneratorFlags& flags);
|
||||
|
||||
static PasswordGenerator* instance();
|
||||
|
||||
private:
|
||||
public:
|
||||
PasswordGenerator();
|
||||
|
||||
QVector<PasswordGroup> passwordGroups(const PasswordGenerator::CharClasses& classes,
|
||||
const PasswordGenerator::GeneratorFlags& flags);
|
||||
int numCharClasses(const PasswordGenerator::CharClasses& classes);
|
||||
void setLength(int length);
|
||||
void setCharClasses(const CharClasses& classes);
|
||||
void setFlags(const GeneratorFlags& flags);
|
||||
|
||||
static PasswordGenerator* m_instance;
|
||||
bool isValid() const;
|
||||
|
||||
QString generatePassword() const;
|
||||
|
||||
private:
|
||||
QVector<PasswordGroup> passwordGroups() const;
|
||||
int numCharClasses() const;
|
||||
|
||||
int m_length;
|
||||
CharClasses m_classes;
|
||||
GeneratorFlags m_flags;
|
||||
|
||||
Q_DISABLE_COPY(PasswordGenerator)
|
||||
};
|
||||
|
||||
inline PasswordGenerator* passwordGenerator() {
|
||||
return PasswordGenerator::instance();
|
||||
}
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PasswordGenerator::CharClasses)
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(PasswordGenerator::GeneratorFlags)
|
||||
|
||||
39
src/core/ToDbExporter.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Felix Geyer <debfx@fobos.de>
|
||||
* Copyright (C) 2014 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 "ToDbExporter.h"
|
||||
#include "core/Database.h"
|
||||
#include "core/Group.h"
|
||||
#include "core/Metadata.h"
|
||||
|
||||
Database* ToDbExporter::exportGroup(Group* group)
|
||||
{
|
||||
Database* oldDb = group->database();
|
||||
Q_ASSERT(oldDb);
|
||||
|
||||
Database* db = new Database();
|
||||
Group* clonedGroup = group->clone(Entry::CloneNewUuid | Entry::CloneIncludeHistory);
|
||||
clonedGroup->setParent(db->rootGroup());
|
||||
|
||||
QSet<Uuid> customIcons = group->customIconsRecursive();
|
||||
db->metadata()->copyCustomIcons(customIcons, oldDb->metadata());
|
||||
|
||||
db->copyAttributesFrom(oldDb);
|
||||
|
||||
return db;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Florian Geyer <blueice@fobos.de>
|
||||
* Copyright (C) 2014 Felix Geyer <debfx@fobos.de>
|
||||
* Copyright (C) 2014 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
|
||||
@@ -15,23 +16,18 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_ARGUMENTPARSER_H
|
||||
#define KEEPASSX_ARGUMENTPARSER_H
|
||||
#ifndef KEEPASSX_TODBEXPORTER_H
|
||||
#define KEEPASSX_TODBEXPORTER_H
|
||||
|
||||
#include "core/Global.h"
|
||||
#include "core/Exporter.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QStringList>
|
||||
class Database;
|
||||
class Group;
|
||||
|
||||
class ArgumentParser
|
||||
class ToDbExporter : Exporter
|
||||
{
|
||||
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;
|
||||
Database* exportGroup(Group* group);
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ARGUMENTPARSER_H
|
||||
#endif // KEEPASSX_TODBEXPORTER_H
|
||||
@@ -30,7 +30,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h> // for Sleep()
|
||||
#include <windows.h> // for Sleep(), SetDllDirectoryA() and SetSearchPathMode()
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
@@ -39,10 +39,12 @@
|
||||
|
||||
#include "config-keepassx.h"
|
||||
|
||||
#if defined(HAVE_RLIMIT_CORE)
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PR_SET_DUMPABLE)
|
||||
#include <sys/prctl.h>
|
||||
#elif defined(HAVE_RLIMIT_CORE)
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PT_DENY_ATTACH
|
||||
@@ -158,6 +160,16 @@ bool isHex(const QByteArray& ba)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isBase64(const QByteArray& ba)
|
||||
{
|
||||
QRegExp regexp("^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$",
|
||||
Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||
|
||||
QString base64 = QString::fromLatin1(ba.constData(), ba.size());
|
||||
|
||||
return regexp.exactMatch(base64);
|
||||
}
|
||||
|
||||
void sleep(int ms)
|
||||
{
|
||||
Q_ASSERT(ms >= 0);
|
||||
@@ -222,21 +234,23 @@ QString platform()
|
||||
|
||||
void disableCoreDumps()
|
||||
{
|
||||
bool success = false;
|
||||
// default to true
|
||||
// there is no point in printing a warning if this is not implemented on the platform
|
||||
bool success = true;
|
||||
|
||||
// prefer PR_SET_DUMPABLE since that also prevents ptrace
|
||||
#if defined(HAVE_PR_SET_DUMPABLE)
|
||||
success = (prctl(PR_SET_DUMPABLE, 0) == 0);
|
||||
#elif defined(HAVE_RLIMIT_CORE)
|
||||
#if defined(HAVE_RLIMIT_CORE)
|
||||
struct rlimit limit;
|
||||
limit.rlim_cur = 0;
|
||||
limit.rlim_max = 0;
|
||||
success = (setrlimit(RLIMIT_CORE, &limit) == 0);
|
||||
success = success && (setrlimit(RLIMIT_CORE, &limit) == 0);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PR_SET_DUMPABLE)
|
||||
success = success && (prctl(PR_SET_DUMPABLE, 0) == 0);
|
||||
#endif
|
||||
|
||||
// Mac OS X
|
||||
#ifdef HAVE_PT_DENY_ATTACH
|
||||
// make sure setrlimit() and ptrace() succeeded
|
||||
success = success && (ptrace(PT_DENY_ATTACH, 0, 0, 0) == 0);
|
||||
#endif
|
||||
|
||||
@@ -245,4 +259,13 @@ void disableCoreDumps()
|
||||
}
|
||||
}
|
||||
|
||||
void setupSearchPaths()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
// Make sure Windows doesn't load DLLs from the current working directory
|
||||
SetDllDirectoryA("");
|
||||
SetSearchPathMode(BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
@@ -35,10 +35,12 @@ bool readAllFromDevice(QIODevice* device, QByteArray& data);
|
||||
QDateTime currentDateTimeUtc();
|
||||
QString imageReaderFilter();
|
||||
bool isHex(const QByteArray& ba);
|
||||
bool isBase64(const QByteArray& ba);
|
||||
void sleep(int ms);
|
||||
void wait(int ms);
|
||||
QString platform();
|
||||
void disableCoreDumps();
|
||||
void setupSearchPaths();
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
|
||||
127
src/core/Translator.cpp
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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/>.
|
||||
*/
|
||||
|
||||
#include "Translator.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QLocale>
|
||||
#include <QRegExp>
|
||||
#include <QTranslator>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "core/Config.h"
|
||||
#include "core/FilePath.h"
|
||||
|
||||
void Translator::installTranslator()
|
||||
{
|
||||
QString language = config()->get("GUI/Language").toString();
|
||||
if (language == "system" || language.isEmpty()) {
|
||||
language = QLocale::system().name();
|
||||
}
|
||||
|
||||
if (!installTranslator(language)) {
|
||||
// English fallback still needs translations for plurals
|
||||
if (!installTranslator("en_plurals")) {
|
||||
qWarning("Couldn't load translations.");
|
||||
}
|
||||
}
|
||||
|
||||
installQtTranslator(language);
|
||||
|
||||
availableLanguages();
|
||||
}
|
||||
|
||||
QList<QPair<QString, QString> > Translator::availableLanguages()
|
||||
{
|
||||
QStringList paths;
|
||||
#ifdef QT_DEBUG
|
||||
paths.append(QString("%1/share/translations").arg(KEEPASSX_BINARY_DIR));
|
||||
#endif
|
||||
paths.append(filePath()->dataPath("translations"));
|
||||
|
||||
QList<QPair<QString, QString> > languages;
|
||||
languages.append(QPair<QString, QString>("system", "System default"));
|
||||
|
||||
QRegExp regExp("keepassx_([a-zA-Z_]+)\\.qm", Qt::CaseInsensitive, QRegExp::RegExp2);
|
||||
Q_FOREACH (const QString& path, paths) {
|
||||
Q_FOREACH (const QString& filename, QDir(path).entryList()) {
|
||||
if (regExp.exactMatch(filename)) {
|
||||
QString langcode = regExp.cap(1);
|
||||
if (langcode == "en_plurals") {
|
||||
langcode = "en";
|
||||
}
|
||||
|
||||
QLocale locale(langcode);
|
||||
QString languageStr = QLocale::languageToString(locale.language());
|
||||
QString countryStr;
|
||||
if (langcode.contains("_")) {
|
||||
countryStr = QString(" (%1)").arg(QLocale::countryToString(locale.country()));
|
||||
}
|
||||
|
||||
QPair<QString, QString> language(langcode, languageStr + countryStr);
|
||||
languages.append(language);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return languages;
|
||||
}
|
||||
|
||||
bool Translator::installTranslator(const QString& language)
|
||||
{
|
||||
QStringList paths;
|
||||
#ifdef QT_DEBUG
|
||||
paths.append(QString("%1/share/translations").arg(KEEPASSX_BINARY_DIR));
|
||||
#endif
|
||||
paths.append(filePath()->dataPath("translations"));
|
||||
|
||||
Q_FOREACH (const QString& path, paths) {
|
||||
if (installTranslator(language, path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Translator::installTranslator(const QString& language, const QString& path)
|
||||
{
|
||||
QTranslator* translator = new QTranslator(qApp);
|
||||
if (translator->load(QString("keepassx_").append(language), path)) {
|
||||
QCoreApplication::installTranslator(translator);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
delete translator;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Translator::installQtTranslator(const QString& language)
|
||||
{
|
||||
QTranslator* qtTranslator = new QTranslator(qApp);
|
||||
if (qtTranslator->load(QString("%1/qt_%2").arg(QLibraryInfo::location(QLibraryInfo::TranslationsPath), language))) {
|
||||
QCoreApplication::installTranslator(qtTranslator);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
delete qtTranslator;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
36
src/core/Translator.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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/>.
|
||||
*/
|
||||
|
||||
#ifndef KEEPASSX_TRANSLATOR_H
|
||||
#define KEEPASSX_TRANSLATOR_H
|
||||
|
||||
#include <QPair>
|
||||
#include <QString>
|
||||
|
||||
class Translator
|
||||
{
|
||||
public:
|
||||
static void installTranslator();
|
||||
static QList<QPair<QString, QString> > availableLanguages();
|
||||
|
||||
private:
|
||||
static bool installTranslator(const QString& language);
|
||||
static bool installTranslator(const QString& language, const QString& path);
|
||||
static bool installQtTranslator(const QString& language);
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_TRANSLATOR_H
|
||||
305
src/core/qcommandlineoption.cpp
Normal file
@@ -0,0 +1,305 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Laszlo Papp <lpapp@kde.org>
|
||||
** Copyright (C) 2013 David Faure <faure@kde.org>
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qcommandlineoption.h"
|
||||
|
||||
#include <QSet>
|
||||
|
||||
class QCommandLineOptionPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
inline QCommandLineOptionPrivate()
|
||||
{ }
|
||||
|
||||
void setNames(const QStringList &nameList);
|
||||
|
||||
//! The list of names used for this option.
|
||||
QStringList names;
|
||||
|
||||
//! The documentation name for the value, if one is expected
|
||||
//! Example: "-o <file>" means valueName == "file"
|
||||
QString valueName;
|
||||
|
||||
//! The description used for this option.
|
||||
QString description;
|
||||
|
||||
//! The list of default values used for this option.
|
||||
QStringList defaultValues;
|
||||
};
|
||||
|
||||
/*!
|
||||
\since 5.2
|
||||
\class QCommandLineOption
|
||||
\brief The QCommandLineOption class defines a possible command-line option.
|
||||
\inmodule QtCore
|
||||
\ingroup shared
|
||||
\ingroup tools
|
||||
|
||||
This class is used to describe an option on the command line. It allows
|
||||
different ways of defining the same option with multiple aliases possible.
|
||||
It is also used to describe how the option is used - it may be a flag (e.g. \c{-v})
|
||||
or take an argument (e.g. \c{-o file}).
|
||||
|
||||
Examples:
|
||||
\snippet code/src_corelib_tools_qcommandlineoption.cpp 0
|
||||
|
||||
\sa QCommandLineParser
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a command line option object with the given arguments.
|
||||
|
||||
The name of the option is set to \a name.
|
||||
The name can be either short or long. If the name is one character in
|
||||
length, it is considered a short name. Option names must not be empty,
|
||||
must not start with a dash or a slash character, must not contain a \c{=}
|
||||
and cannot be repeated.
|
||||
|
||||
The description is set to \a description. It is customary to add a "."
|
||||
at the end of the description.
|
||||
|
||||
In addition, the \a valueName can be set if the option expects a value.
|
||||
The default value for the option is set to \a defaultValue.
|
||||
|
||||
\sa setDescription(), setValueName(), setDefaultValues()
|
||||
*/
|
||||
QCommandLineOption::QCommandLineOption(const QString &name, const QString &description,
|
||||
const QString &valueName,
|
||||
const QString &defaultValue)
|
||||
: d(new QCommandLineOptionPrivate)
|
||||
{
|
||||
d->setNames(QStringList(name));
|
||||
setValueName(valueName);
|
||||
setDescription(description);
|
||||
setDefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a command line option object with the given arguments.
|
||||
|
||||
This overload allows to set multiple names for the option, for instance
|
||||
\c{o} and \c{output}.
|
||||
|
||||
The names of the option are set to \a names.
|
||||
The names can be either short or long. Any name in the list that is one
|
||||
character in length is a short name. Option names must not be empty,
|
||||
must not start with a dash or a slash character, must not contain a \c{=}
|
||||
and cannot be repeated.
|
||||
|
||||
The description is set to \a description. It is customary to add a "."
|
||||
at the end of the description.
|
||||
|
||||
In addition, the \a valueName can be set if the option expects a value.
|
||||
The default value for the option is set to \a defaultValue.
|
||||
|
||||
\sa setDescription(), setValueName(), setDefaultValues()
|
||||
*/
|
||||
QCommandLineOption::QCommandLineOption(const QStringList &names, const QString &description,
|
||||
const QString &valueName,
|
||||
const QString &defaultValue)
|
||||
: d(new QCommandLineOptionPrivate)
|
||||
{
|
||||
d->setNames(names);
|
||||
setValueName(valueName);
|
||||
setDescription(description);
|
||||
setDefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a QCommandLineOption object that is a copy of the QCommandLineOption
|
||||
object \a other.
|
||||
|
||||
\sa operator=()
|
||||
*/
|
||||
QCommandLineOption::QCommandLineOption(const QCommandLineOption &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys the command line option object.
|
||||
*/
|
||||
QCommandLineOption::~QCommandLineOption()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Makes a copy of the \a other object and assigns it to this QCommandLineOption
|
||||
object.
|
||||
*/
|
||||
QCommandLineOption &QCommandLineOption::operator=(const QCommandLineOption &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the names set for this option.
|
||||
*/
|
||||
QStringList QCommandLineOption::names() const
|
||||
{
|
||||
return d->names;
|
||||
}
|
||||
|
||||
void QCommandLineOptionPrivate::setNames(const QStringList &nameList)
|
||||
{
|
||||
QStringList newNames;
|
||||
if (nameList.isEmpty())
|
||||
qWarning("QCommandLineOption: Options must have at least one name");
|
||||
Q_FOREACH (const QString &name, nameList) {
|
||||
if (name.isEmpty()) {
|
||||
qWarning("QCommandLineOption: Option names cannot be empty");
|
||||
} else {
|
||||
const QChar c = name.at(0);
|
||||
if (c == QLatin1Char('-'))
|
||||
qWarning("QCommandLineOption: Option names cannot start with a '-'");
|
||||
else if (c == QLatin1Char('/'))
|
||||
qWarning("QCommandLineOption: Option names cannot start with a '/'");
|
||||
else if (name.contains(QLatin1Char('=')))
|
||||
qWarning("QCommandLineOption: Option names cannot contain a '='");
|
||||
else
|
||||
newNames.append(name);
|
||||
}
|
||||
}
|
||||
// commit
|
||||
names = newNames;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the name of the expected value, for the documentation, to \a valueName.
|
||||
|
||||
Options without a value assigned have a boolean-like behavior:
|
||||
either the user specifies --option or they don't.
|
||||
|
||||
Options with a value assigned need to set a name for the expected value,
|
||||
for the documentation of the option in the help output. An option with names \c{o} and \c{output},
|
||||
and a value name of \c{file} will appear as \c{-o, --output <file>}.
|
||||
|
||||
Call QCommandLineParser::argument() if you expect the option to be present
|
||||
only once, and QCommandLineParser::arguments() if you expect that option
|
||||
to be present multiple times.
|
||||
|
||||
\sa valueName()
|
||||
*/
|
||||
void QCommandLineOption::setValueName(const QString &valueName)
|
||||
{
|
||||
d->valueName = valueName;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the name of the expected value.
|
||||
|
||||
If empty, the option doesn't take a value.
|
||||
|
||||
\sa setValueName()
|
||||
*/
|
||||
QString QCommandLineOption::valueName() const
|
||||
{
|
||||
return d->valueName;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the description used for this option to \a description.
|
||||
|
||||
It is customary to add a "." at the end of the description.
|
||||
|
||||
The description is used by QCommandLineParser::showHelp().
|
||||
|
||||
\sa description()
|
||||
*/
|
||||
void QCommandLineOption::setDescription(const QString &description)
|
||||
{
|
||||
d->description = description;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the description set for this option.
|
||||
|
||||
\sa setDescription()
|
||||
*/
|
||||
QString QCommandLineOption::description() const
|
||||
{
|
||||
return d->description;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the default value used for this option to \a defaultValue.
|
||||
|
||||
The default value is used if the user of the application does not specify
|
||||
the option on the command line.
|
||||
|
||||
If \a defaultValue is empty, the option has no default values.
|
||||
|
||||
\sa defaultValues() setDefaultValues()
|
||||
*/
|
||||
void QCommandLineOption::setDefaultValue(const QString &defaultValue)
|
||||
{
|
||||
QStringList newDefaultValues;
|
||||
if (!defaultValue.isEmpty()) {
|
||||
newDefaultValues << defaultValue;
|
||||
}
|
||||
// commit:
|
||||
d->defaultValues = newDefaultValues;
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the list of default values used for this option to \a defaultValues.
|
||||
|
||||
The default values are used if the user of the application does not specify
|
||||
the option on the command line.
|
||||
|
||||
\sa defaultValues() setDefaultValue()
|
||||
*/
|
||||
void QCommandLineOption::setDefaultValues(const QStringList &defaultValues)
|
||||
{
|
||||
d->defaultValues = defaultValues;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the default values set for this option.
|
||||
|
||||
\sa setDefaultValues()
|
||||
*/
|
||||
QStringList QCommandLineOption::defaultValues() const
|
||||
{
|
||||
return d->defaultValues;
|
||||
}
|
||||