Skip to content

Commit

Permalink
Merge branch 'develop' into feature/3279-choose-backup-location
Browse files Browse the repository at this point in the history
  • Loading branch information
libklein authored Nov 5, 2021
2 parents 2bccaf8 + 7811f10 commit 00394c6
Show file tree
Hide file tree
Showing 13 changed files with 276 additions and 38 deletions.
1 change: 1 addition & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ Files: share/icons/application/scalable/actions/chevron-double-down.svg
share/icons/application/scalable/actions/statistics.svg
share/icons/application/scalable/actions/system-help.svg
share/icons/application/scalable/actions/system-search.svg
share/icons/application/scalable/actions/trash.svg
share/icons/application/scalable/actions/url-copy.svg
share/icons/application/scalable/actions/username-copy.svg
share/icons/application/scalable/actions/view-history.svg
Expand Down
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<file>application/scalable/actions/system-help.svg</file>
<file>application/scalable/actions/system-search.svg</file>
<file>application/scalable/actions/system-software-update.svg</file>
<file>application/scalable/actions/trash.svg</file>
<file>application/scalable/actions/url-copy.svg</file>
<file>application/scalable/actions/user-guide.svg</file>
<file>application/scalable/actions/username-copy.svg</file>
Expand Down
49 changes: 49 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5710,6 +5710,34 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>Wordlist:</source>
<translation>Wordlist:</translation>
</message>
<message>
<source>Delete selected wordlist</source>
<translation>Delete selected wordlist</translation>
</message>
<message>
<source>Do you really want to delete the wordlist &quot;%1&quot;?</source>
<translation>Do you really want to delete the wordlist &quot;%1&quot;?</translation>
</message>
<message>
<source>Failed to delete wordlist</source>
<translation>Failed to delete wordlist</translation>
</message>
<message>
<source>Add custom wordlist</source>
<translation>Add custom wordlist</translation>
</message>
<message>
<source>Wordlists</source>
<translation>Wordlists</translation>
</message>
<message>
<source>All files</source>
<translation>All files</translation>
</message>
<message>
<source>Failed to add wordlist</source>
<translation>Failed to add wordlist</translation>
</message>
<message>
<source>Word Separator:</source>
<translation>Word Separator:</translation>
Expand Down Expand Up @@ -5894,6 +5922,27 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>character</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(SYSTEM)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Confirm Delete Wordlist</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select Custom Wordlist</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Overwrite Wordlist?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Wordlist &quot;%1&quot; already exists as a custom wordlist.
Do you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PickcharsDialog</name>
Expand Down
67 changes: 59 additions & 8 deletions src/autotype/xcb/AutoTypeXCB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,23 @@ void AutoTypePlatformX11::updateKeymap()
}
m_xkb = XkbGetMap(m_dpy, XkbAllClientInfoMask, XkbUseCoreKbd);

/* workaround X11 bug https://gitlab.freedesktop.org/xorg/xserver/-/issues/1155 */
XkbSetMap(m_dpy, XkbAllClientInfoMask, m_xkb);
XSync(m_dpy, False);

/* Build updated keymap */
m_keymap.clear();
m_remapKeycode = 0;

for (int ckeycode = m_xkb->min_key_code; ckeycode < m_xkb->max_key_code; ckeycode++) {
int groups = XkbKeyNumGroups(m_xkb, ckeycode);

/* track highest remappable keycode, don't add to keymap */
if (groups == 0) {
m_remapKeycode = ckeycode;
continue;
}

for (int cgroup = 0; cgroup < groups; cgroup++) {
XkbKeyTypePtr type = XkbKeyKeyType(m_xkb, ckeycode, cgroup);

Expand Down Expand Up @@ -357,6 +368,7 @@ void AutoTypePlatformX11::SendKeyEvent(unsigned keycode, bool press)

XTestFakeKeyEvent(m_dpy, keycode, press, 0);
XFlush(m_dpy);
XSync(m_dpy, False);

XSetErrorHandler(oldHandler);
}
Expand Down Expand Up @@ -399,9 +411,43 @@ bool AutoTypePlatformX11::GetKeycode(KeySym keysym, int* keycode, int* group, un
return true;
}

/* if we can't find an existing key for this keysym, try remapping */
if (RemapKeycode(keysym)) {
*keycode = m_remapKeycode;
*group = 0;
*mask = 0;
return true;
}

return false;
}

/*
* Get remapped keycode for any keysym.
*/
bool AutoTypePlatformX11::RemapKeycode(KeySym keysym)
{
if (!m_remapKeycode) {
return false;
}

if (keysym != NoSymbol) {
int type = XkbOneLevelIndex;
if (XkbChangeTypesOfKey(m_xkb, m_remapKeycode, 1, XkbGroup1Mask, &type, NULL) != Success) {
return false;
}

XkbKeySymEntry(m_xkb, m_remapKeycode, 0, 0) = keysym;
} else {
XkbChangeTypesOfKey(m_xkb, m_remapKeycode, 0, XkbGroup1Mask, NULL, NULL);
}

XkbSetMap(m_dpy, XkbAllClientInfoMask, m_xkb);
XFlush(m_dpy);
XSync(m_dpy, False);
return true;
}

/*
* Send sequence of KeyPressed/KeyReleased events to the focused
* window to simulate keyboard. If modifiers (shift, control, etc)
Expand All @@ -426,14 +472,6 @@ AutoTypeAction::Result AutoTypePlatformX11::sendKey(KeySym keysym, unsigned int
/* tell GetKeycode we would prefer a key from active group */
group = group_active;

/* determine keycode, group and mask for the given keysym */
if (!GetKeycode(keysym, &keycode, &group, &wanted_mask)) {
return AutoTypeAction::Result::Failed(tr("Unable to get valid keycode for key: ")
+ QString(XKeysymToString(keysym)));
}

wanted_mask |= modifiers;

Window root, child;
int root_x, root_y, x, y;
unsigned int original_mask;
Expand All @@ -451,6 +489,14 @@ AutoTypeAction::Result AutoTypePlatformX11::sendKey(KeySym keysym, unsigned int
return AutoTypeAction::Result::Retry(tr("Sequence aborted: Modifier keys held by user"));
}

/* determine keycode, group and mask for the given keysym */
if (!GetKeycode(keysym, &keycode, &group, &wanted_mask)) {
return AutoTypeAction::Result::Failed(tr("Unable to get valid keycode for key: ")
+ QString(XKeysymToString(keysym)));
}

wanted_mask |= modifiers;

/* modifiers that need to be held but aren't */
unsigned int press_mask = wanted_mask & ~original_mask;

Expand All @@ -474,6 +520,11 @@ AutoTypeAction::Result AutoTypePlatformX11::sendKey(KeySym keysym, unsigned int
XFlush(m_dpy);
}

/* reset remap to prevent leaking remap keysyms longer than necessary */
if (keycode == m_remapKeycode) {
RemapKeycode(NoSymbol);
}

return AutoTypeAction::Result::Ok();
}

Expand Down
3 changes: 2 additions & 1 deletion src/autotype/xcb/AutoTypeXCB.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
bool isTopLevelWindow(Window window);

XkbDescPtr getKeyboard();
int AddKeysym(KeySym keysym);
bool RemapKeycode(KeySym keysym);
void SendKeyEvent(unsigned keycode, bool press);
void SendModifiers(unsigned int mask, bool press);
bool GetKeycode(KeySym keysym, int* keycode, int* group, unsigned int* mask);
Expand Down Expand Up @@ -88,6 +88,7 @@ class AutoTypePlatformX11 : public QObject, public AutoTypePlatformInterface
XkbDescPtr m_xkb;
QList<KeyDesc> m_keymap;
KeyCode m_modifier_keycode[N_MOD_INDICES];
KeyCode m_remapKeycode;
bool m_loaded;
};

Expand Down
6 changes: 0 additions & 6 deletions src/browser/BrowserSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,6 @@ void BrowserSettingsWidget::loadSettings()
m_ui->snapWarningLabel->setVisible(false);
#endif

// TODO: Enable Edge support when Linux version is released
#ifdef Q_OS_LINUX
m_ui->edgeSupport->setChecked(false);
m_ui->edgeSupport->setEnabled(false);
#endif

#ifdef KEEPASSXC_DIST_SNAP
// Disable settings that will not work
m_ui->useCustomProxy->setChecked(false);
Expand Down
4 changes: 2 additions & 2 deletions src/browser/NativeMessageInstaller.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2017 Sami Vänttinen <[email protected]>
* Copyright (C) 2017 KeePassXC Team <[email protected]>
* Copyright (C) 2021 KeePassXC Team <[email protected]>
*
* 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
Expand Down Expand Up @@ -70,7 +70,7 @@ namespace
const QString TARGET_DIR_TOR_BROWSER = QStringLiteral(
"/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts");
const QString TARGET_DIR_BRAVE = QStringLiteral("/BraveSoftware/Brave-Browser/NativeMessagingHosts");
const QString TARGET_DIR_EDGE = QStringLiteral("/microsoftedge/NativeMessagingHosts");
const QString TARGET_DIR_EDGE = QStringLiteral("/microsoft-edge/NativeMessagingHosts");
#endif
} // namespace

Expand Down
7 changes: 7 additions & 0 deletions src/core/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <QLibrary>

#include "config-keepassx.h"
#include "core/Config.h"
#include "core/Global.h"

Resources* Resources::m_instance(nullptr);
Expand Down Expand Up @@ -91,6 +92,12 @@ QString Resources::wordlistPath(const QString& name) const
return dataPath(QStringLiteral("wordlists/%1").arg(name));
}

QString Resources::userWordlistPath(const QString& name) const
{
QString configPath = QFileInfo(config()->getFileName()).absolutePath();
return configPath + QStringLiteral("/wordlists/%1").arg(name);
}

Resources::Resources()
{
const QString appDirPath = QCoreApplication::applicationDirPath();
Expand Down
1 change: 1 addition & 0 deletions src/core/Resources.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Resources
QString dataPath(const QString& name) const;
QString pluginPath(const QString& name) const;
QString wordlistPath(const QString& name) const;
QString userWordlistPath(const QString& name) const;

static Resources* instance();

Expand Down
Loading

0 comments on commit 00394c6

Please sign in to comment.