Compare commits

...

332 Commits

Author SHA1 Message Date
Felix Geyer
c8857ac2ba Finalize changelog. 2016-09-04 17:57:47 +02:00
Felix Geyer
367fbbba39 Update translations. 2016-09-04 17:14:15 +02:00
Felix Geyer
abf469f743 Prepare for 2.0.3 release. 2016-09-03 22:05:22 +02:00
Felix Geyer
878995366a Ask the user before moving an entry to the recycle bin.
Closes #447
2016-09-02 12:00:12 +02:00
Felix Geyer
1635a5211f Pass entryFlags to clone() when recursing into sub-groups.
Based on https://github.com/keepassx/keepassx/pull/178 by Mois Moshev <mois@monomon.me>

Closes #525
2016-09-02 11:47:22 +02:00
Felix Geyer
595b1011dd Refresh fileInfo after creating the file.
Fixes canonicalFilePath() returning an empty string.
2016-09-02 11:35:39 +02:00
Felix Geyer
9bb291235d Fix monospace font on Windows.
Closes #424
2016-09-02 11:35:39 +02:00
Felix Geyer
7d4ef0b8d0 Generate new password whenever the generator widget is opened.
Closes #414
2016-09-02 11:35:39 +02:00
Florian Geyer
8d16522d39 Repair UUID of inconsistent history items.
Closes #130
2016-08-03 23:48:40 +02:00
Felix Geyer
cd1192b409 Allow deleting the recycle bin.
Closes #46
2016-08-03 23:45:04 +02:00
Felix Geyer
bf2fd63131 Fix crash when deleting parent group of recycle bin.
In these cases delete the group instead of trying to move it to the recycle bin.

Closes #520
2016-08-03 23:27:02 +02:00
Felix Geyer
9532bedd7d Update min. length for password generator.
Update the minimum length for the password generator depending on the chosen
options.

Closes #420
2016-07-31 22:07:47 +02:00
Felix Geyer
e9c8363b70 Save to canonical file path so we don't overwrite symlinks.
When saving a database we previously replaced symlinks with a regular file.

Closes #442
2016-07-31 18:29:43 +02:00
Felix Geyer
fb57ed2bcd Add proper error handling when QSaveFile::open() fails.
Based on pull request by Valeriy <jazzvoid@gmail.com>

Closes #450
2016-07-31 17:07:31 +02:00
Felix Geyer
57ec558396 Detect image format solely on content.
Otherwise reading fails if the file extension is wrong.

Closes #512
2016-07-31 15:36:29 +02:00
Felix Geyer
6e2de1cd79 Display proper error message when reading an icon fails.
Refs #512
2016-07-31 14:44:45 +02:00
Felix Geyer
8ace3ab7f2 Don't consider windows with WithdrawnState as top level windows.
Fixes many bogus windows in auto-type window list when using gnome-shell.
2016-07-31 14:44:45 +02:00
Felix Geyer
18e4dca6c9 Explicitly include QFile in TestKeePass2Writer.
Closes #452
2016-07-31 14:44:45 +02:00
Felix Geyer
48eca3e11f Display an error message when opening the database fails.
Closes #462
2016-05-20 16:49:32 +02:00
Felix Geyer
57c1a0f4b6 Show proper error message when key is wrong for .kdb files. 2016-04-09 16:09:53 +02:00
Felix Geyer
bde4d63fdb Fix typo. 2016-04-09 16:02:49 +02:00
Felix Geyer
4867d26f7d Update optional dependencies in the README. 2016-02-13 11:24:11 +01:00
Felix Geyer
9bd3ab717e Print libXtst instead of libXtest in the feature summary.
The protocol is called XTEST but the library libxtst.

Closes #440
2016-02-13 11:13:15 +01:00
Felix Geyer
3679b21701 Fix typo in changelog. 2016-02-02 01:22:48 +01:00
Felix Geyer
49f58b4ed8 Prepare 2.0.2 release. 2016-02-02 01:21:39 +01:00
Felix Geyer
235361faf4 Explicitly cast char constant to QChar. 2016-02-02 00:57:28 +01:00
Felix Geyer
208b803fbe Fix KeePass2Repair to retain multi-byte UTF-8 chars.
Since char is (often) unsigned the ch < 0x20 check matched all
multi-byte encoded UTF-8 chars.
2016-02-02 00:41:16 +01:00
Felix Geyer
8a92cec03f Keep valid surrogate pairs in stripInvalidXml10Chars(). 2016-02-02 00:38:58 +01:00
Felix Geyer
00f068b93e Fix typo in changelog. 2016-01-31 20:00:44 +01:00
Felix Geyer
654353e26b Update translations. 2016-01-31 19:03:25 +01:00
Felix Geyer
d670ef2638 Prepare for 2.0.1 release. 2016-01-31 18:49:35 +01:00
Felix Geyer
aff935b3c7 Properly handle a missing key filename. 2016-01-31 17:08:50 +01:00
Felix Geyer
107c0673c7 Make sure we don't write negative icon ids into the database. 2016-01-31 17:06:51 +01:00
Felix Geyer
c14d04b3e8 Fix crash when icon id is larger than INT_MAX.
In these cases icon id was interpreted as a negative number.
The QList access with a negative index resulted in a crash.
2016-01-31 16:44:34 +01:00
Felix Geyer
7a017041bf Allow opening databases that have no password and keyfile.
Closes #391
2016-01-31 16:17:24 +01:00
Felix Geyer
eb56bd8973 Add repair functionality to strip invalid XML chars.
Refs #392
2016-01-28 23:07:04 +01:00
Felix Geyer
93585aded7 Always display scaled custom icons.
Closes #322
2016-01-26 22:44:38 +01:00
Felix Geyer
38245aa2a9 Add iconScaledPixmap() convenience functions. 2016-01-24 20:12:33 +01:00
Felix Geyer
1f33e6f044 Add Metadata::customIconScaledPixmap(). 2016-01-24 20:12:33 +01:00
Felix Geyer
4752adf9d3 Move pixmap caching to Metadata. 2016-01-24 20:12:21 +01:00
Felix Geyer
2d741afe3e Strip invalid XML chars when writing databases.
These characters are unprintable or just plain invalid.
QXmlStreamReader throws and error when reading XML documents with such chars.

Closes #392
2016-01-24 17:20:16 +01:00
Florian Geyer
5e6b17aba4 Disable password generator button when showing entry in history mode.
Closes #422
2016-01-22 22:55:28 +01:00
Florian Geyer
c51098e2cf Flush temporary file before opening attachment.
Closes #390
2015-12-16 21:38:20 +01:00
Felix Geyer
24275d8dc4 Bump version. 2015-12-06 22:19:05 +01:00
Felix Geyer
94d82948f6 Update translations. 2015-12-06 21:06:06 +01:00
Felix Geyer
54fb1abb96 Update changelog. 2015-12-06 21:03:00 +01:00
Felix Geyer
a3b936fcd0 Coding style fixes. 2015-12-06 20:27:09 +01:00
Felix Geyer
efc4cd5969 Merge remote-tracking branch 'github/pr/74' 2015-12-06 19:21:38 +01:00
Felix Geyer
17ab438c5a Make sure Windows doesn't load DLLs from the current working directory. 2015-12-06 14:32:06 +01:00
Felix Geyer
77b4bfb14e Cleanup string argument numbers. 2015-12-06 14:31:23 +01:00
Felix Geyer
7839280cb3 Check if the tray icon is visible before minimizing to it. 2015-11-01 23:32:37 +01:00
Felix Geyer
9e1ea264e2 Use availableGeometry() to calculate the dialog position.
availableGeometry() excludes ares where windows can't be placed (e.g. panels).
2015-11-01 23:26:40 +01:00
Felix Geyer
b02ec98ec6 Show AutoTypeSelectDialog on the active desktop.
This wasn't always the case on X11 with virtual desktops.

Closes #359
2015-11-01 23:23:01 +01:00
Felix Geyer
2fa531745f Check XML key file for valid base64 before using it.
QByteArray::fromBase64() doesn't validate the input.

Closes #366
2015-11-01 18:32:15 +01:00
Felix Geyer
820941fd40 Auto-Type: Only require a substring match for regex.
This matches the behavior of KeePass.

Refs #357
2015-10-10 17:36:08 +02:00
Felix Geyer
862941abf6 TestAutoType: Restore AutoTypeEntryTitleMatch before every test. 2015-10-10 17:23:57 +02:00
Felix Geyer
e98c30f633 Disable systray on OS X.
It's not useful on that platform.

Refs #326
2015-10-10 17:10:29 +02:00
Felix Geyer
316a7e6fb7 Expose version of used libraries in the About dialog. 2015-10-10 17:10:29 +02:00
Felix Geyer
58ed99d562 OS X: Restore main window when clicking on the docker icon.
Apparently this worked previously. Maybe a regression in Qt?

Refs #326
2015-10-10 17:10:27 +02:00
Felix Geyer
840642394f Cope with focusWidget/activeWindow returning windows that are minimized. 2015-10-10 12:07:28 +02:00
Florian Geyer
ebeedba072 Reset visibility state of password field on unlocking.
Closes #354
2015-09-28 22:30:29 +02:00
Felix Geyer
568dfde074 Fix minimum size of AboutDialog.
Also make the dialog non-resizeable.

Closes #352
2015-09-28 22:08:33 +02:00
Felix Geyer
b8c1829857 Improve tray icon behavior on OS X.
Previously the main window had issues on restore:
- was sometimes hidden again.
- window was unresponsive, all actions disabled.
2015-09-27 23:16:18 +02:00
Felix Geyer
4f2d56a55f Fix another small memory leak. 2015-09-26 12:41:53 +02:00
Felix Geyer
6b49f8f26b Free input device list.
Fixes a memory leak.
2015-09-26 12:41:53 +02:00
Felix Geyer
fc8cb7cd14 Check if XListInputDevices returns an error.
Refs #351
2015-09-26 12:41:52 +02:00
Felix Geyer
727094abc6 Unload auto-type plugins if they run in an unsupported environment.
Refs #351
2015-09-26 12:41:47 +02:00
Felix Geyer
bcb54bc38a Avoid dereferencing QLists. 2015-09-25 21:34:56 +02:00
Felix Geyer
14aac09318 Avoid implicit casts from bool to int. 2015-09-25 21:34:56 +02:00
Felix Geyer
9d42db9849 Mark more methods as override. 2015-09-25 21:34:56 +02:00
Felix Geyer
ee81c7c00e Remove WITH_LTO option.
It's broken and probably not worth the potential again.

Refs #353
2015-09-25 21:34:51 +02:00
Felix Geyer
2edf414aa4 Fix compiler warning on OS X and Windows. 2015-09-24 18:45:23 +02:00
Felix Geyer
54f44f5267 Show a better message when trying to open an old database format.
Refs #338
2015-09-23 23:16:49 +02:00
Felix Geyer
6ab54bc95a Check if libXi is installed and explicitly link against it. 2015-09-23 22:26:49 +02:00
Felix Geyer
673dff2268 Auto-Type: Raise target window after showing the select dialog.
kwin >= 5.4 (since commit cfa1d61) prefers to focus the main window
instead of following the focus chain.

We ask the window manager nicely to focus the window we want to
type into. kwin seems to follow that (in the default configuration).
2015-09-21 23:12:10 +02:00
Felix Geyer
bb38be40f6 Enable Ctrl+M shortcut to minimize window on all platforms.
Closes #329
2015-09-13 22:33:07 +02:00
Felix Geyer
f236c32063 Clear clipboard when locking databases.
Closes #342
2015-09-13 12:38:19 +02:00
Felix Geyer
236edae60b travis-ci: Backport OS X improvements from master. 2015-09-12 23:35:59 +02:00
Felix Geyer
a954e9a4d8 Update translations. 2015-09-06 23:41:29 +02:00
Felix Geyer
95c449481e Prepare beta 2 release. 2015-09-06 23:39:54 +02:00
Felix Geyer
0b43607aa1 Make sure we use the native file dialog on Windows and OS X. 2015-09-06 13:32:12 +02:00
Felix Geyer
e75efb8bfb Improve setting the default file extension in FileDialog.
Largely from PR #105 by Charles Brunet <charles@cbrunet.net>
2015-09-05 19:10:26 +02:00
Felix Geyer
d83fee89bd Fix building WITH_CXX11 on OS X. 2015-09-05 19:03:24 +02:00
Akinori MUSHA
b773dbe645 Test if hitting the Down key moves the focus to the entry view. 2015-08-05 19:02:17 +09:00
Akinori MUSHA
5c7c7f54fa Improve UI of the search edit.
- The copy action (Control+C) when no text is selected copies the
  password of the current entry.  This should be reasonable when
  Control+B copies the username.

- Down at EOL moves the focus to the entry view.  Enter and Tab should
  do that, but it would be handy for user to be able to get to the third
  entry by hitting Down three times.
2015-08-05 19:02:17 +09:00
Felix Geyer
98417d6465 Set default extension when selected filename doesn't have one.
Closes #79
2015-07-25 18:16:33 +02:00
Felix Geyer
0ea64afe92 Fix type of default value for options. 2015-07-25 18:13:57 +02:00
Felix Geyer
a862f62fe8 Set a default filename when saving a new database.
Closes #308
2015-07-25 17:47:45 +02:00
Felix Geyer
5bd525a6dd Use correct keycode when unregistering global shortcuts.
charToKeySym() is already correctly used in registerGlobalShortcut().
2015-07-22 20:38:03 +02:00
Felix Geyer
af3d896bdf Make setNativeLocks() non-fatal on OS X. 2015-07-21 23:12:20 +02:00
Felix Geyer
ceeb72a277 Pull QLockFile updates from the qtbase repository. 2015-07-21 23:11:02 +02:00
Felix Geyer
2c17fdcff0 Correct link order of testhashedblockstream.
Fixes FTBFS on Windows.
2015-07-21 23:08:12 +02:00
Florian Geyer
41a7c96968 Close search before locking database and add additional check on current group.
Closes #309.
2015-07-20 22:45:57 +02:00
Felix Geyer
98d9dae087 Test if reset() and close() write only one final block. 2015-07-20 21:51:32 +02:00
Felix Geyer
2033174d95 Test if we correctly detect errors when writing. 2015-07-20 21:35:48 +02:00
Felix Geyer
606e36acf3 Detect and display more errors when writing databases. 2015-07-20 21:35:48 +02:00
Felix Geyer
0422943d52 Explicitly close/reset streams so we can detect errors. 2015-07-20 21:35:48 +02:00
Felix Geyer
0024f2e30f Signal errors in QXmlStreamWriter upstream.
Unfortunately the method is only avaiable in Qt >= 4.8.
Not much we can do about that.
2015-07-20 21:35:43 +02:00
Felix Geyer
abe5e8ecea Don't write final block(s) if we already have. 2015-07-20 21:33:51 +02:00
Felix Geyer
61503a8047 SymmetricCipherStream: Add error handling when reading from the device. 2015-07-20 19:54:18 +02:00
Felix Geyer
fcb5deff0a SymmetricCipherStream: Fix error string when detecting an error while writing. 2015-07-20 19:53:17 +02:00
Felix Geyer
fdec16c3a0 Fix copyright file match for username-copy.png. 2015-07-19 21:16:22 +02:00
Felix Geyer
84ee8b993f Explicity hide the tray icon before deleting it.
In some conditions the tray icon stayed visible until the application
was closed.
Tested on Kubuntu 15.04 (KDE Plasma 5.2).
2015-07-19 21:14:08 +02:00
Felix Geyer
3d1c27ceb7 Copy the database in TestGui before opening it.
We don't want to create lock files in the source tree.
2015-07-19 19:33:47 +02:00
Felix Geyer
7d3fb58cf5 Fix lock file location in saveDatabaseAs().
Previously the directory of the lock file path was empty when
saving to a new file.
saveFile.open() doesn't create the file and canonicalPath()
only works when the file exists.
2015-07-19 00:41:35 +02:00
Felix Geyer
df5da2fcef Fix lock file handling in saveDatabaseAs(). 2015-07-18 22:46:45 +02:00
Felix Geyer
1226d1dbd5 Prepare next release. 2015-07-18 21:20:38 +02:00
Felix Geyer
607007f94f Display country in language list.
But only if the translation specifies one.
2015-07-18 18:38:41 +02:00
Felix Geyer
6327eaf587 Fix tab name for read-only databases. 2015-07-18 18:29:19 +02:00
Felix Geyer
b1fd99f4c4 Enable document mode of DatabaseTabWidget.
This fixes a visual artifact when the GTK style is used and
only one database tab is open.

Closes #131
2015-07-18 18:27:17 +02:00
Felix Geyer
d1331053c8 Document GetGitRevisionDescription.cmake license. 2015-07-18 17:37:48 +02:00
Felix Geyer
c6fe0da569 Abort closing the app if saving a database failed. 2015-07-18 17:36:08 +02:00
Florian Geyer
b9fe2c1bf9 Small clean up. 2015-07-18 13:23:36 +02:00
Florian Geyer
3efc8f457a Display git revision in about dialog. 2015-07-18 13:14:13 +02:00
Felix Geyer
65e8732eeb Remove --password command line option.
Passing passwords on the command line is unsafe.
2015-07-17 21:31:36 +02:00
Felix Geyer
e82015d419 Update translations. 2015-07-17 20:54:28 +02:00
Florian Geyer
fa0fe6d33d Make tab order consistent. 2015-07-16 23:50:35 +02:00
Felix Geyer
8be135adf9 Merge remote-tracking branch 'github/pr/54' 2015-07-16 23:12:52 +02:00
Jerome Leclanche
d04927ce7f Use a better GenericName 2015-07-16 23:07:21 +02:00
Felix Geyer
6889cc2f20 Another Qt 4.6 compatibility fix. 2015-07-16 22:55:50 +02:00
Felix Geyer
8325b20d36 Make QElapsedTimer optional in QLockFile.
This restores compatibility with Qt 4.6.
2015-07-16 21:52:08 +02:00
Felix Geyer
826cd472c8 Group all copy to clipboard menu entries together. 2015-07-16 20:09:23 +02:00
Felix Geyer
8ecab15c33 Merge remote-tracking branch 'github/pr/112'
Closes #149
2015-07-16 20:06:44 +02:00
Felix Geyer
c9520214e2 Merge remote-tracking branch 'github/pr/72' 2015-07-16 20:04:26 +02:00
Felix Geyer
6d1ca363af Remove support for clearing the Klipper history.
KDE Plasma 5 doesn't provide the DBus interface anymore and
this avoids the QtDBus dependency.
2015-07-16 20:02:10 +02:00
Felix Geyer
2170794d9c Guess the scheme when opening URLs.
Closes #293
2015-07-16 19:52:34 +02:00
Felix Geyer
719ac64851 Fix unused variable warning. 2015-07-16 19:49:41 +02:00
Felix Geyer
d3a7e0dee9 Merge remote-tracking branch 'github/pr/108' 2015-07-16 19:32:07 +02:00
Felix Geyer
240919335f Add missing EmptyUuids.xml test file. 2015-07-14 22:20:56 +02:00
Felix Geyer
ceb6a0383e Add ability to export databases to CSV files.
Based on implementation by Florian Geyer <blueice@fobos.de>

Closes #57
2015-07-14 22:14:34 +02:00
Felix Geyer
0185b112e1 Merge remote-tracking branch 'github/pr/92'
https://github.com/keepassx/keepassx/pull/92
2015-07-13 22:43:58 +02:00
Felix Geyer
af84261eb6 Avoid calling QDesktopServices::openUrl() when cmd is empty. 2015-07-13 22:41:03 +02:00
Felix Geyer
274f86fd04 Merge branch 'pr-94'
https://github.com/keepassx/keepassx/pull/94

Closes #244
2015-07-13 22:36:56 +02:00
Felix Geyer
bcc3108c3d Coding style cleanup. 2015-07-13 22:36:20 +02:00
Felix Geyer
5f1b286630 Merge branch 'pr-95'
https://github.com/keepassx/keepassx/pull/95

Closes #283
2015-07-13 22:22:45 +02:00
Felix Geyer
8ad48d6774 Protect against emitting inactivityDetected() while it'is still processed. 2015-07-13 21:25:48 +02:00
Felix Geyer
721bec9794 Make sure we don't lock the database while a dialog is open.
This can happen when
- the user is picking out a file to save the database as
- a dialog asking the user to save/discard/cancel the current database
  changes is active

It is dangerous to lock the databases while these actions are still
in progress.

Closes #208
2015-07-13 21:25:38 +02:00
Felix Geyer
c6105a08ab KeePass2XmlReader: Don't fail wheh nreading empty UUIDs.
Closes #298
2015-07-13 21:01:55 +02:00
Felix Geyer
154f1673e9 QSaveFile: Flush temporary file and fsync before renaming.
Closes #301
2015-07-13 21:01:53 +02:00
Felix Geyer
577609b3e3 Make calling QSaveFile::commit() non-fatal if it's not open. 2015-07-13 21:00:50 +02:00
Florian Geyer
f22069bb11 Use higher increment for transform rounds in benchmark.
Thanks to Sami Farin for providing a patch.

Closes #305.
2015-07-12 21:48:55 +02:00
Codifier
280a1aceb9 Bug #149
Moved the actionEntryCopyUsername and actionEntryCopyPassword actions to the root level of the context menu, for easier access and changed their labels to 'Copy username' and 'Copy password', respectively.
2015-07-12 20:54:02 +02:00
Andy Zeigler
bcd3de1180 Add keyboard shortcut (Ctrl-Alt-U) for copy URL to clipboard. 2015-06-12 19:29:02 -07:00
Florian Geyer
f4361dd4d5 Fix enabled state of copy notes action. 2015-06-05 18:37:22 +02:00
Felix Geyer
fc43aa1717 Update translations. 2015-05-15 00:20:23 +02:00
Felix Geyer
d553698b20 Travis CI: Pass --output-on-failure to ctest. 2015-05-14 20:46:59 +02:00
Felix Geyer
7db9c78855 Ignore libgcrypt errors in CryptoHash::CryptoHash().
Postponed until after 2.0 when I'll use excpetions.

Should be safe as we check basic functioning in Crypto::testSha256().
2015-05-14 20:44:17 +02:00
Felix Geyer
7a2c02f0df Initialize some instance variables in ctor.
Discovered by Coverity.

Most likely doesn't fix any actual bug but better be safe.
2015-05-14 16:58:53 +02:00
Felix Geyer
c535736853 Add GUI for changing default group auto-type sequence.
Closes #175
2015-05-14 12:59:36 +02:00
Felix Geyer
a8bf6a9782 Refactor Tools::disableCoreDumps().
- Use all available methods.
- Don't print a warning when no method is implmeneted on the platform.
2015-05-14 12:58:00 +02:00
Amir Pakdel
0458dad6dc Code cleanups 2015-05-13 14:34:48 -04:00
Felix Geyer
68373730bf Fix compiler warnings where keysyms are printed.
%lX expectes unsigned long which KeySym is an alias for.
2015-05-12 23:57:36 +02:00
Felix Geyer
5d9039ea89 Silence compiler warning about an unused variable. 2015-05-12 23:40:02 +02:00
Felix Geyer
7e1faadd11 Merge remote-tracking branch 'github/pr/96'
Closes #218
2015-05-12 23:35:19 +02:00
Felix Geyer
fceb93061d Merge remote-tracking branch 'github/pr/97'
Closes #290
2015-05-12 22:31:51 +02:00
Amir Pakdel
c9d007fcdf Always clearing ChangeMasterKeyWidget.m_key 2015-05-12 16:31:14 -04:00
Felix Geyer
eeb940c0dc Fix plugin path detection when installed with DESTDIR.
This is in no way perfect but should cover most common cases.

Closes #291
2015-05-12 22:24:59 +02:00
Felix Geyer
05b5446e94 Protect opened databases with a file lock.
Closes #18
2015-05-12 22:24:45 +02:00
Amir Pakdel
b45437d502 Refactored DatabaseWidget::currentEntryHas*() 2015-05-12 15:54:39 -04:00
Amir Pakdel
a599787a25 Bug #290
Show realted menu option to current entry only if the corresponding
field is not empty.
2015-05-12 15:50:10 -04:00
Amir Pakdel
58061af959 Bug #218
Do not accept faulty files as Key File. Moreover, do not clear keys
unless we have a key to add.
2015-05-12 15:17:39 -04:00
Amir Pakdel
8bf1bb0517 Bug #283
Updated messages related to saivng and closing a database to make
them more clear about what is going to happen.
2015-05-12 13:46:48 -04:00
Amir Pakdel
d26cff520f Bug #244
Supporting cmd:// URLs
2015-05-12 12:25:43 -04:00
dartraiden
04aa10cee7 Russian translation for .desktop file 2015-05-12 00:14:58 +03:00
Felix Geyer
ade684d501 Crypto::selfTest(): test AES in ECB mode. 2015-05-10 00:02:08 +02:00
Felix Geyer
4362c3ea38 Handle cipher errors in TransformKeyBenchmarkThread. 2015-05-09 23:38:04 +02:00
Felix Geyer
e0d4b4b625 Adapt Salsa20 backend to the new interface. 2015-05-09 23:21:50 +02:00
Felix Geyer
cfffdae573 Improve error reporing of layered streams. 2015-05-09 23:21:50 +02:00
Felix Geyer
f6243675c9 Warn if result of processInPlace() is unchecked.
Fix callers accordingly.
2015-05-09 23:21:50 +02:00
Felix Geyer
a762cef0a9 Catch and handle all errors from libgcrypt. 2015-05-09 23:21:44 +02:00
Felix Geyer
a7f4e2d0cd Add Twofish tests to Crypto::selfTest(). 2015-05-09 18:15:01 +02:00
Felix Geyer
ae013c2196 Don't run gcrypt self tests.
Seems to be broken on some distros that enable hmac verification
of the binary but ship the signature in a separate package.

We have our own test cases for the algorithms we care about.
2015-05-09 17:32:52 +02:00
Felix Geyer
eefe844dcd Merge remote-tracking branch 'github/pr/80'
https://github.com/keepassx/keepassx/pull/80
2015-05-06 20:56:57 +02:00
Felix Geyer
94111c3662 Merge remote-tracking branch 'github/pr/90'
https://github.com/keepassx/keepassx/pull/90
2015-05-06 20:53:56 +02:00
dartraiden
3fca61dc24 spelling correction, fixed typos 2015-05-06 19:38:43 +03:00
Felix Geyer
e41bf008e9 Use Q_BYTE_ORDER for endianness detection.
A hardcoded list of architectures is always incomplete.
2015-05-03 20:00:23 +02:00
Felix Geyer
6c9c0fd5c5 Look for a close button when pressing the escape key. 2015-05-03 19:59:11 +02:00
Felix Geyer
f3d956ceed Display a Close button for history items.
Previously we had Ok and Cancel with the same action.
2015-05-03 18:59:19 +02:00
Felix Geyer
b9c9c56059 Use common EditEntryWidget::clear() method. 2015-05-03 18:58:44 +02:00
Felix Geyer
bed58cde84 Fix crash when pressing "cancel" on a history item. 2015-05-03 18:48:58 +02:00
Felix Geyer
855d79e28f Document the libxtst dependency. 2015-05-01 19:34:57 +02:00
Felix Geyer
a044467d10 Install desktop file and icons to DATADIR instead of the hardcoded share/. 2015-04-14 23:23:14 +02:00
Felix Geyer
ecb2e337ef Hide Auto-Type action when it's not available. 2015-04-14 23:12:10 +02:00
Felix Geyer
2dde18b179 Adjust coding style. 2015-04-14 23:10:37 +02:00
Felix Geyer
6411b9bd66 Merge remote-tracking branch 'github/pr/82'
https://github.com/keepassx/keepassx/pull/82

Closes #145
2015-04-14 23:07:14 +02:00
Felix Geyer
cf0bc32b27 Store icons with a resolution of up to 128x128 px.
Follows what KeePass 2.29 will implement.
2015-04-08 18:22:13 +02:00
Felix Geyer
93ab7eb058 Use CMAKE_INSTALL_DATADIR to look for the data dir. 2015-04-08 18:07:53 +02:00
Felix Geyer
bd3ae05fcf Rename Extras menu to Tools and move Lock Databases action to it. 2015-04-05 10:48:08 +02:00
Felix Geyer
b055d524e8 Merge branch 'lockdb' 2015-04-05 10:38:58 +02:00
Felix Geyer
9e051e835b Close databases when they are locked.
Previously we've only hidden access to them.

Closes #275
2015-04-05 10:38:36 +02:00
Felix Geyer
3ab1072e9e Scale new custom icons down to 64x64 if they are larger. 2015-03-31 22:31:04 +02:00
Joe Harvell
00df73ced0 Issue #270 - turning off key location memory
Add general settting for whether or not to remember last key files
2015-03-14 22:06:53 -05:00
Felix Geyer
940a5026c1 Properly auto-type line breaks and tabs in text. 2015-03-13 22:24:29 +01:00
Felix Geyer
2631277184 Always sleep some time after the keymap has changed.
This works around a problem where sometimes chars are typed as if some
random modifiers are pressed.
2015-03-13 21:58:04 +01:00
Felix Geyer
b86b640860 Process events from the event loop before typing the first char. 2015-03-13 19:45:57 +01:00
Felix Geyer
2dfc740782 Rework handling of modifiers in auto-type.
Release all modifiers that are pressed and change the result.
2015-03-13 19:43:52 +01:00
Felix Geyer
e4985f4ff7 Get the xtest keyboard instead of the core keyboard.
If we don't find it fall back to the core keyboard.
2015-03-13 19:41:49 +01:00
Felix Geyer
22f579a59e Restore keyboard mapping only if we actually changed it. 2015-03-13 19:40:52 +01:00
Ben Boeckel
c9d12e93c2 cmake: remove the LOCATION query
Newer CMake deprecates the property. It isn't necessary anyways since
add_test will recognize targets as the executable name and make the full
path automatically.
2015-02-26 00:30:06 -05:00
Felix Geyer
778f01bcf1 Increase sleep time after remapping a keycode. 2015-02-24 22:00:44 +01:00
Felix Geyer
ccb7a4c96d Blacklist the KDE 5 root window. 2015-02-24 21:59:47 +01:00
Felix Geyer
33650c4a04 Add non-const version of Group::groupsRecursive(). 2015-01-11 16:20:24 +01:00
Victor Häggqvist
019cf9684c change tabindex, put password inputs after each other 2015-01-01 02:25:43 +01:00
Felix Geyer
835c411d12 Merge branch 'knu-fix_opening_attachment'
https://github.com/keepassx/keepassx/pull/71
2014-12-22 16:11:48 +01:00
Akinori MUSHA
e4758c1984 Fix the temporary filename template so that the original suffix is preserved. 2014-12-22 23:47:16 +09:00
Felix Geyer
eb22f0a2d8 Raise an error when parsing duplicate attributes/attachments. 2014-12-03 23:36:53 +01:00
Felix Geyer
3ea0592b53 Add hasKey() convenience methods. 2014-12-03 23:36:24 +01:00
Felix Geyer
876a75b572 Disable attachment buttons when none is selected. 2014-12-03 23:26:42 +01:00
Felix Geyer
c39898dad9 Support opening attachments directly. 2014-12-03 21:50:17 +01:00
Felix Geyer
07a3d7a696 Merge branch 'elrob-master'
https://github.com/keepassx/keepassx/pull/68
2014-12-02 08:34:30 +01:00
Rob Speller
7f412fbd7f Remove confusing grammar
Sentence still had 'either' because the sentence used to include twofish
2014-12-01 22:21:49 +00:00
Florian Geyer
2adc64939f Correct handling of keyfile argument.
Closes #223.
2014-12-01 22:47:22 +01:00
Felix Geyer
71d39865b3 Introduce a strict mode in KeePass2XmlReader.
Many errors are now ignored when not in strict mode so we can still parse
files that have been written by broken/incomplete implementations.
2014-12-01 21:52:51 +01:00
Felix Geyer
226c061c01 Remove Twofish reference from the README.
It isn't supported anymore.
2014-11-30 23:38:08 +01:00
Felix Geyer
dd2fbebb81 Add a translations section to the README. 2014-11-30 23:34:16 +01:00
Felix Geyer
889c742a33 Expand the build-dependency section of the README. 2014-11-30 23:31:25 +01:00
Felix Geyer
5cc3334325 Small README corrections. 2014-11-30 23:25:04 +01:00
Felix Geyer
e58be44523 Wrap overly long lines in README.md. 2014-11-30 23:23:29 +01:00
Felix Geyer
34a7321786 Merge branch 'hbetts-readme'
https://github.com/keepassx/keepassx/pull/46
2014-11-30 23:20:52 +01:00
Felix Geyer
07e4fbacd4 Remove ModifiedOnExpandedStateChanges config option.
I'm pretty sure noone knew what it actually does.
This is the sort of option users shouldn't be bothered with.
2014-11-30 23:04:17 +01:00
Felix Geyer
8fd69e084e Merge branch 'knu-untoggle_find'
https://github.com/keepassx/keepassx/pull/66
2014-11-30 22:54:23 +01:00
Akinori MUSHA
dd79105baa Complete remove the toggle search action. 2014-11-19 11:46:38 +09:00
Akinori MUSHA
b1c3814972 Make Ctrl+F not toggle the search mode but always enable it.
Switching back from other applications, the previous behavior of Ctrl+F
would often bother you in that it would dismiss the search widget if it
was already enabled when you meant by the key you wanted to perform a
search.

Making Ctrl+F always set you in search mode should save user from having
to care about the mode which is persistent across application switching
and database locking.
2014-11-18 19:46:53 +09:00
Felix Geyer
57107ea560 Enable debug mode for Travis CI builds. 2014-11-04 18:51:46 +01:00
Felix Geyer
4b3a82592c Define QT_NO_DEBUG for build type None.
Debian sets the the build type to None for package builds.
Make sure we don't enable asserts there.

Closes #237
2014-11-04 18:50:59 +01:00
Felix Geyer
6ecb8690f2 Update translations. 2014-11-02 15:42:39 +01:00
Felix Geyer
1c365b8417 Add Travis CI config. 2014-11-02 12:55:46 +01:00
Felix Geyer
315df0b8a8 Coding style fixes. 2014-11-02 11:46:51 +01:00
Felix Geyer
87468b648b Use specific monospace fonts as fallback on Mac OS X.
Qt (4.8.6) doesn't seem to be able to resolve the generic monospace
font family.

Closes #214
2014-11-02 11:44:03 +01:00
Felix Geyer
4cdb9a645d Add an option to display a tray icon.
Also implement "Minimize to tray" functionality.
2014-11-02 11:44:03 +01:00
Felix Geyer
870d7355ca Fix reading window title from _NET_WM_NAME.
XGetWindowProperty() returns 0 on success.

Closes #236
2014-11-02 11:44:03 +01:00
Florian Geyer
f1aa6aca26 Fix copy custom attributes menu. 2014-10-09 21:36:08 +02:00
Florian Geyer
72b59d541a Clear available languages when loading settings.
Thanks to Victor Häggqvist for spotting this.
2014-09-05 10:12:35 +02:00
Felix Geyer
0e8aa0bc6c Merge branch 'yayachiken-yayachiken-dev'
https://github.com/keepassx/keepassx/pull/58
2014-06-16 18:08:49 +02:00
David Kolossa
3a0648cf25 ! binds stronger than ==
This should just avoid useless copying if more than 1 attribute is
selected (and the option to copy attributes is unavailable).

This also fixes a clang warning.
2014-06-16 15:40:28 +02:00
David Kolossa
2e76385cae Fixed typo in INSTALL 2014-06-16 13:08:39 +02:00
Felix Geyer
867d14f7aa Merge branch 'movestill-fixConfigPath'
https://github.com/keepassx/keepassx/pull/49
2014-06-15 13:20:17 +02:00
Felix Geyer
0d6117bf4c Do some basic self-checks when initializing the crypto backend. 2014-06-15 11:17:40 +02:00
Felix Geyer
b417bf9187 Enable C++11 by default. 2014-06-13 21:33:36 +02:00
Felix Geyer
7137990a21 Clear clipboard only if copied text is still present.
Closes #198
2014-05-26 18:41:48 +02:00
Felix Geyer
916ab99d62 Skip TestQSaveFile::transactionalWriteErrorRenaming as user root.
You can't deny root access to a file.

Closes #201
2014-05-26 18:24:43 +02:00
Felix Geyer
5a31e055cf Show the window title when no entry matches for auto-type.
Closes #188
2014-05-18 12:09:46 +02:00
Felix Geyer
28694ae687 Add initial support for translations. 2014-05-18 01:33:22 +02:00
Felix Geyer
becd3a0019 Increase the EntryView default column size a bit. 2014-05-17 19:01:43 +02:00
Felix Geyer
8cc1e6008e Use plurals in translations. 2014-05-17 18:17:31 +02:00
Felix Geyer
910788c038 Mark some strings as untranslatable. 2014-05-17 18:17:31 +02:00
Felix Geyer
9391de74c7 Block non-user updates in DatabaseWidgetStateSync. 2014-05-17 18:17:31 +02:00
Florian Geyer
c806f9ebf4 Correct tr-calls. 2014-05-17 18:13:22 +02:00
Felix Geyer
e776de8eeb Remember and synchronize entry column sizes.
Closes #159
2014-05-17 12:51:16 +02:00
Felix Geyer
a25b28ffee Rename config option window/Geometry to GUI/MainWindowGeometry. 2014-05-17 11:38:48 +02:00
Felix Geyer
0e75e6ff03 Make DatabaseWidget splitter non-collapsible. 2014-05-17 11:27:04 +02:00
Felix Geyer
76da4a6cd4 Use QSplitter::setStretchFactor() convenience method. 2014-05-17 11:25:45 +02:00
Felix Geyer
8a4100adbd Make DatabaseWidget::emit{Group,Entry}ContextMenuRequested() private. 2014-05-17 11:22:45 +02:00
Felix Geyer
584f4b50bf Coding style fix. 2014-05-17 11:21:50 +02:00
Felix Geyer
9ac01c930d Drop DatabaseWidget::groupView() and entryView(). 2014-05-17 11:21:17 +02:00
Felix Geyer
d874f58a39 Synchronize DatabaseWidget splitter sizes. 2014-05-17 11:16:27 +02:00
Florian Geyer
05de45dadb Improve tab order. 2014-05-16 19:49:58 +02:00
Felix Geyer
4ab887c773 Initally select first entry in EntryView.
Closes #104
2014-05-16 19:10:30 +02:00
Florian Geyer
552ca7bf71 Stop search timer when closing search. 2014-05-16 18:56:01 +02:00
Felix Geyer
2d8ba2b394 Focus the search field instead of closing it when pressing the shortcut.
Closes #124
2014-05-16 13:10:26 +02:00
Felix Geyer
a6d44034a4 Put test executables into their default location. 2014-05-16 13:10:26 +02:00
Florian Geyer
77af79498c Move QTEST_GUILESS_MAIN statements before test cases. 2014-05-16 12:32:52 +02:00
Florian Geyer
ea3375490c Introduce interface for exporter. 2014-05-16 12:32:06 +02:00
Florian Geyer
204cd8d971 Move exporter to separate class. 2014-05-16 12:07:22 +02:00
Florian Geyer
c2940a8f18 Extend TestEntrySearcher. 2014-05-16 10:51:22 +02:00
Florian Geyer
4f60df029d Refactor TestEntrySearcher. 2014-05-16 00:26:09 +02:00
Florian Geyer
819cfd459a Move match method out of entry class. 2014-05-16 00:19:58 +02:00
Florian Geyer
c90ac914bb Refactor TestEntrySearcher. 2014-05-15 23:59:26 +02:00
Florian Geyer
8bf4826003 Move search into separate class. 2014-05-15 23:50:40 +02:00
Felix Geyer
e361b0dd81 Fix typo canDeleteCurrentGoup() -> canDeleteCurrentGroup(). 2014-05-15 22:56:36 +02:00
Felix Geyer
ce7e01a1b1 const-ify several methods. 2014-05-15 22:53:59 +02:00
Felix Geyer
cda5e990ac Show in-edit-mode warning when database is locked. 2014-05-15 22:51:13 +02:00
Florian Geyer
50cbd80925 Remove obsolete method in EntryView. 2014-05-15 18:55:17 +02:00
Felix Geyer
75d3e6261b Coding style fix. 2014-05-15 18:41:11 +02:00
Felix Geyer
bf39d0b1be Enable entry title matching but always ask before performing auto-type. 2014-05-15 18:34:12 +02:00
Felix Geyer
147cd4ed7b Add option to use the entry title for auto-type window matching. 2014-05-15 18:30:57 +02:00
Florian Geyer
9363d23e09 Remove dependency to Group- and EntryView from MainWindow. 2014-05-15 18:05:58 +02:00
Florian Geyer
b718e9d8f2 Make sure copy actions are disabled when database is locked.
Closes #189
2014-05-03 08:28:56 +02:00
Tim Gion
d6c30b0886 Fixed location of config file on Mac (and probably Windows). 2014-04-30 22:26:39 -04:00
Hutson Betts
7c7f0b93ae Add README.md file.
Add a dedicated README.md to the KeePassX repository to explain the
purpose of KeePassX, and to inform it's audience as to how they can
contribute.
2014-04-28 22:09:24 -05:00
Felix Geyer
e263c475c9 Increase default number of transform rounds to 100000.
Even low-end smartphone should be able to handle that.
2014-04-26 18:34:33 +02:00
Felix Geyer
c917096d3c Show the inherited value in EditGroupWidget. 2014-04-26 18:34:26 +02:00
Felix Geyer
5de62a5ef4 Add Group::resolveAutoTypeEnabled(). 2014-04-26 18:30:22 +02:00
Felix Geyer
7893a2e84d Rename Group::includeInSearch() to resolveSearchingEnabled().
Make it public and drop the resolveInherit parameter.
2014-04-26 18:27:52 +02:00
Florian Geyer
ad26d962dc Add option in settings for using group icons for newly created entries.
Closes #174
2014-04-14 23:38:09 +02:00
Florian Geyer
967a9f0195 Add check if parent group has custom icon.
Refs #174
2014-04-14 23:20:24 +02:00
Charles Brunet
6c663a19bf Use folder icon when not defaut icon 2014-04-14 22:59:38 +02:00
Felix Geyer
b194c29166 Show a dialog when no window matches for auto-type. 2014-04-14 22:57:25 +02:00
Felix Geyer
0b9167c78b Add an option to always ask before performing auto-type.
Closes #120
2014-04-14 22:57:18 +02:00
Felix Geyer
63ae460a80 Fix the alpha 6 release date. 2014-04-12 15:45:09 +02:00
Felix Geyer
43a1d54bba Prepare 2.0 alpha 6 release. 2014-04-12 15:29:20 +02:00
Felix Geyer
2963752585 Disallow global auto-typing when the database is locked. 2014-04-12 15:29:03 +02:00
Florian Geyer
1decdc6c11 Only save geometry when close event is accepted. 2014-03-24 20:03:40 +01:00
Florian Geyer
6659745e2b Rename settings key for window geometry. 2014-03-24 20:03:40 +01:00
Florian Geyer
1e2d1a1b17 Refactor saving of window geometry.
Closes #154
2014-03-24 20:03:40 +01:00
Florian Geyer
f300ca5b7b Remember window size.
Refs #154
2014-03-24 20:03:40 +01:00
Felix Geyer
b9370c6e79 More careful null checking and member initalization. 2014-03-22 12:10:49 +01:00
Florian Geyer
54bb7462f6 Add find action to entries menu.
Closes #122
2014-03-08 11:42:26 +01:00
Florian Geyer
4a08101a60 Remove obsolete ArgumentParser files. 2014-03-08 10:45:40 +01:00
Felix Geyer
809be5f89e Use the correct modifiers after remapping.
Sometimes the keysym is not mapped to the first column (no modifiers)
but to a diffferent column that needs modifiers.
Therefore we need re-read the table and search the whole row for the
correct keysym.
2014-01-19 23:32:00 +01:00
Felix Geyer
bf9a755bea Check all modifiers before declaring the remap keycode invalid.
Sometimes XChangeKeyboardMapping() maps the keysym to a modifier.
2014-01-19 21:40:25 +01:00
Felix Geyer
34b82da9aa Initialize cur_focus before it's used. 2014-01-19 20:09:19 +01:00
Felix Geyer
e0c59395da Merge branch 'AlbertWeichselbraun-bug-116-autotype-single-keycode' 2014-01-19 20:06:12 +01:00
Felix Geyer
b07de47e35 Add transform key benchmark to TestKeys. 2014-01-19 15:26:32 +01:00
Felix Geyer
586de64293 Restore compatibility with old Qt versions. 2014-01-19 10:46:53 +01:00
Felix Geyer
9321943e64 Install mime info package on Linux. 2014-01-18 23:43:44 +01:00
Felix Geyer
c00550078c Add KeePass 2 document icons. 2014-01-18 23:35:34 +01:00
Felix Geyer
2190260a68 Small optimization in SymmetricCipherGcrypt::processInPlace(). 2014-01-18 20:47:45 +01:00
Felix Geyer
678c4a8ece Set the application name and version in QApplication. 2014-01-18 15:31:24 +01:00
Felix Geyer
c2781274a0 Fix include guards of config-keepassx.h. 2014-01-18 15:30:58 +01:00
Felix Geyer
bc14898b13 Replace ArgumentParser with a backport of QCommandLineParser from Qt 5.2. 2014-01-18 15:23:55 +01:00
Felix Geyer
b6497d9245 Coding style fixes. 2014-01-14 21:00:27 +01:00
Felix Geyer
79d827ffa4 Add 22x22 icons for actions that are in the toolbar. 2014-01-14 19:55:38 +01:00
Felix Geyer
811eb2714f Add copy username and password actions to the clipboard.
Also add corresponding icons that I've put together from
various Oxygen icons.
2014-01-14 19:53:42 +01:00
Felix Geyer
a914b837a1 Drop new database action from the toolbar.
It's not a common operation.
2014-01-14 19:40:20 +01:00
Felix Geyer
04c9332a99 Drop superfluous PasswordGeneratorWidget::togglePassword slot. 2014-01-13 21:40:23 +01:00
Felix Geyer
97f374a189 Use monospace font in the password generator combo box. 2014-01-13 21:39:55 +01:00
Felix Geyer
6f3648d63e Uncheck the correct widget in ChangeMasterKeyWidget.
We want to enable the password group but mask the password in the line edit.
2014-01-13 00:24:29 +01:00
Felix Geyer
350cf4b00a Move password generator widget to the right row. 2014-01-13 00:24:29 +01:00
Felix Geyer
3af2307468 Reworked the PasswordGeneratorWidget.
It's loosely based on OS X PasswordAssistant. Generation happens as soon as a
change is made, and on open of the widget. A combobox has been added to allow
one to choose from some randomally-generated alternatives, and the UI is
generally been made a bit more compact.

Written by Michael Curtis <michael@moltenmercury.org> and revised by me.

Closes #119

https://github.com/keepassx/keepassx/pull/38
2014-01-13 00:24:25 +01:00
Felix Geyer
29c997e1bc Add an option to show passwords by default.
Closes #93
2014-01-12 17:23:47 +01:00
Felix Geyer
223c5a1651 Use an icon for the button that shows/masks passwords.
Closes #38

Additionally make use of the new PasswordEdit class where possible.
2014-01-12 17:13:10 +01:00
Felix Geyer
8b437821a2 Add ability to load icons with on/off state. 2014-01-12 17:13:10 +01:00
Felix Geyer
4ded95a060 Add PasswordEdit class.
It displays passwords in monospace which closes #51
2014-01-12 17:13:03 +01:00
Felix Geyer
0b6b149351 Use the libgcrypt SALSA20 cipher if available. 2014-01-12 13:42:56 +01:00
Felix Geyer
eee909e948 Parse the libgcrypt version in the cmake module. 2014-01-12 13:42:19 +01:00
Felix Geyer
8c7e655274 Add compatibility with libgcrypt 1.6.
Closes #129
2014-01-12 12:39:39 +01:00
Felix Geyer
8e86437e89 Disable settings spinboxes by default.
They get enabled when the corresponding checkboxes are checked.
2014-01-07 21:58:49 +01:00
Felix Geyer
a8edad1e27 Add option to lock databases after user inactivity.
Closes #62
2014-01-07 21:57:38 +01:00
Felix Geyer
41162ea2e8 Only try to click the focused button when pressing enter.
It makes no sense when pressing the escape button.
2014-01-02 10:51:51 +01:00
Albert Weichselbraun
0f91e0d141 Better naming & actually save m_currentRemapKeysym. 2013-12-16 09:41:43 +01:00
Albert Weichselbraun
6a50a76466 Track the last remapped keysym in m_currentRemapKeycode to enforce
a new computation of m_remapKeycode when the keyboard layout
changes.
(This fixes a potential problem with AddKeysym overwriting
 used keysyms after applying a new keyboard layout).
2013-12-16 09:28:16 +01:00
256 changed files with 39696 additions and 1650 deletions

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
src/version.h.cmake export-subst

21
.travis.yml Normal file
View 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
View 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

View File

@@ -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)
=========================

View File

@@ -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)

View File

@@ -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

View File

@@ -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
View 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
View 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.

View File

@@ -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)

View 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()

View 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()

View File

@@ -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)

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 711 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View 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
View 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>

View 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)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View 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&apos;t delete icon. Still used by %n item(s).</source>
<translation>
<numerusform>Can&apos;t delete icon. Still used by %n item.</numerusform>
<numerusform>Can&apos;t delete icon. Still used by %n items.</numerusform>
</translation>
</message>
</context>
</TS>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

12
share/translations/update.sh Executable file
View 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

View File

@@ -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)

View File

@@ -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);

View File

@@ -89,5 +89,7 @@ void AutoTypeExecutor::execDelay(AutoTypeDelay* action)
void AutoTypeExecutor::execClearField(AutoTypeClearField* action)
{
Q_UNUSED(action);
// TODO: implement
}

View File

@@ -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;

View File

@@ -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);

View File

@@ -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()

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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

View File

@@ -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++;
}

View File

@@ -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);

View File

@@ -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:

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
};

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View 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
View 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
View 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

View File

@@ -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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View 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();
}

View 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

View File

@@ -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();

View File

@@ -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;

View File

@@ -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()
{
}

View File

@@ -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
View 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;
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
View 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
View 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

View 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;
}

Some files were not shown because too many files have changed in this diff Show More