Skip to content

Commit

Permalink
Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
varjolintu committed Jan 11, 2025
1 parent fb02efb commit e04319d
Show file tree
Hide file tree
Showing 24 changed files with 84 additions and 124 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
check_pie_supported()
endif()

# Find Qt5 compatibility library
# Find Qt6 compatibility library
find_package(Qt6 REQUIRED COMPONENTS Core5Compat)

# Find Botan early since the version affects subsequent compiler options
Expand Down
2 changes: 1 addition & 1 deletion share/translations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if(WIN32)
elseif(APPLE OR KEEPASSXC_DIST_APPIMAGE)
file(GLOB QTBASE_TRANSLATIONS
/usr/share/qt/translations/qtbase_*.qm
/usr/share/qt5/translations/qtbase_*.qm
/usr/share/qt6/translations/qtbase_*.qm
${Qt6_PREFIX}/translations/qtbase_*.qm)
endif()
set(QM_FILES ${QM_FILES} ${QTBASE_TRANSLATIONS})
Expand Down
79 changes: 36 additions & 43 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2023 KeePassXC Team <[email protected]>
# Copyright (C) 2025 KeePassXC Team <[email protected]>
# Copyright (C) 2010 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -233,26 +233,26 @@ if(UNIX AND NOT APPLE)
endif()
if(WITH_XC_X11)
list(APPEND gui_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
gui/osutils/nixutils/X11Funcs.cpp)
endif()
qt6_add_dbus_adaptor(keepassx_SOURCES
qt6_add_dbus_adaptor(gui_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
MainWindow)

set_source_files_properties(
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h"
)
qt6_add_dbus_interface(keepassx_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h"
)
qt6_add_dbus_interface(core_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
)

find_library(KEYUTILS_LIBRARIES NAMES keyutils)
if(NOT KEYUTILS_LIBRARIES)
message(FATAL_ERROR "Could not find libkeyutils")
message(FATAL_ERROR "Could not find libkeyutils")
endif()
endif()

Expand Down Expand Up @@ -329,19 +329,19 @@ set(autotype_SOURCES
autotype/WindowSelectComboBox.cpp)

add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt5::Core Qt5::Widgets)
target_link_libraries(autotype Qt6::Core Qt6::Widgets)

if(WITH_XC_YUBIKEY)
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp)
keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp)
else()
list(APPEND core_SOURCES
keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp)
keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp)
endif()

if(WITH_XC_NETWORKING)
Expand All @@ -357,25 +357,13 @@ endif()
configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h)
configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h)

add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt6::Core Qt6::Network Qt6::Widgets)

add_library(keepassx_core STATIC ${keepassx_SOURCES})

find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)

set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core
autotype
${keepassxcbrowser_LIB}
# Core Library Definition
add_library(keepassxc_core STATIC ${core_SOURCES})
set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassxc_core
${qrcode_LIB}
${fdosecrets_LIB}
Qt6::Core
Qt6::Core5Compat
Qt6::Concurrent
Qt6::Network
Qt6::SvgWidgets
Qt6::Widgets
${BOTAN_LIBRARIES}
${PCSC_LIBRARIES}
${ZXCVBN_LIBRARIES}
Expand All @@ -387,27 +375,32 @@ target_link_libraries(keepassx_core

# GUI Library Definition
add_library(keepassxc_gui STATIC ${gui_SOURCES})
find_package(Qt6 REQUIRED COMPONENTS SvgWidgets)
set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassxc_gui
keepassxc_core
Qt5::Network
Qt5::Widgets
Qt6::Network
Qt6::SvgWidgets
Qt6::Widgets
autotype
${browser_LIB}
${fdosecrets_LIB}
${keeshare_LIB}
${sshagent_LIB})

if(APPLE)
target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication -framework ScreenCaptureKit")
target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication -framework ScreenCaptureKit")
if(Qt6MacExtras_FOUND)
target_link_libraries(keepassxc_gui Qt6::MacExtras)
endif()
endif()
if(HAIKU)
target_link_libraries(keepassxc_gui network)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt6::DBus ${LIBUSB_LIBRARIES})
target_link_libraries(keepassxc_core Qt6::DBus ${LIBUSB_LIBRARIES})
if(WITH_XC_X11)
target_link_libraries(keepassx_core Qt6::X11Extras X11)
target_link_libraries(keepassxc_gui Qt6::X11Extras X11)
endif()
include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS})
endif()
Expand Down Expand Up @@ -533,7 +526,7 @@ if(WIN32)
COMPONENT Runtime)

# Use windeployqt.exe to setup Qt dependencies
if(Qt6Core_VERSION VERSION_LESS "6.6.0") # TODO: Check this.
if(Qt6Core_VERSION VERSION_LESS "6.6.0")
set(WINDEPLOYQT_MODE "--release")
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(WINDEPLOYQT_MODE "--debug")
Expand All @@ -548,15 +541,15 @@ if(WIN32)
find_file(OPENSSL_DLL
NAMES libssl-3.dll libssl-3-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
)
)
if (NOT OPENSSL_DLL)
message(FATAL_ERROR "Cannot find libssl dll, ensure openssl is properly installed.")
endif()

find_file(CRYPTO_DLL
NAMES libcrypto-3.dll libcrypto-3-x64.dll
HINTS "${OPENSSL_ROOT_DIR}/bin"
)
)
if (NOT CRYPTO_DLL)
message(FATAL_ERROR "Cannot find libcrypto dll, ensure openssl is properly installed.")
endif()
Expand Down
12 changes: 6 additions & 6 deletions src/autotype/AutoTypeSelectDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,23 +296,23 @@ void AutoTypeSelectDialog::buildActionMenu()
m_actionMenu->addAction(copyPasswordAction);
m_actionMenu->addAction(copyTotpAction);

typeUsernameAction->setShortcut(Qt::CTRL + Qt::Key_1);
typeUsernameAction->setShortcut(Qt::CTRL | Qt::Key_1);
typeUsernameAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::USERNAME);
connect(typeUsernameAction, &QAction::triggered, this, [&] {
auto match = m_ui->view->currentMatch();
match.second = "{USERNAME}";
submitAutoTypeMatch(match);
});

typePasswordAction->setShortcut(Qt::CTRL + Qt::Key_2);
typePasswordAction->setShortcut(Qt::CTRL | Qt::Key_2);
typePasswordAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::PASSWORD);
connect(typePasswordAction, &QAction::triggered, this, [&] {
auto match = m_ui->view->currentMatch();
match.second = "{PASSWORD}";
submitAutoTypeMatch(match);
});

typeTotpAction->setShortcut(Qt::CTRL + Qt::Key_3);
typeTotpAction->setShortcut(Qt::CTRL | Qt::Key_3);
typeTotpAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::TOTP);
connect(typeTotpAction, &QAction::triggered, this, [&] {
auto match = m_ui->view->currentMatch();
Expand All @@ -330,7 +330,7 @@ void AutoTypeSelectDialog::buildActionMenu()
});
#endif

copyUsernameAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_1);
copyUsernameAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_1);
copyUsernameAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::USERNAME);
connect(copyUsernameAction, &QAction::triggered, this, [&] {
auto entry = m_ui->view->currentMatch().first;
Expand All @@ -340,7 +340,7 @@ void AutoTypeSelectDialog::buildActionMenu()
}
});

copyPasswordAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_2);
copyPasswordAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_2);
copyPasswordAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::PASSWORD);
connect(copyPasswordAction, &QAction::triggered, this, [&] {
auto entry = m_ui->view->currentMatch().first;
Expand All @@ -350,7 +350,7 @@ void AutoTypeSelectDialog::buildActionMenu()
}
});

copyTotpAction->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_3);
copyTotpAction->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_3);
copyTotpAction->setProperty(MENU_FIELD_PROP_NAME, MENU_FIELD::TOTP);
connect(copyTotpAction, &QAction::triggered, this, [&] {
auto entry = m_ui->view->currentMatch().first;
Expand Down
2 changes: 1 addition & 1 deletion src/autotype/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(autotype_test_SOURCES AutoTypeTest.cpp)

add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES})
target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt6::Core Qt6::Widgets)
target_link_libraries(keepassxc-autotype-test keepassxc_core ${autotype_LIB} Qt6::Core Qt6::Widgets)
2 changes: 1 addition & 1 deletion src/autotype/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(autotype_win_SOURCES AutoTypeWindows.cpp)

add_library(keepassxc-autotype-windows MODULE ${autotype_win_SOURCES})
target_link_libraries(keepassxc-autotype-windows keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-windows keepassxc_gui ${autotype_LIB} Qt6::Core Qt6::Widgets)
install(TARGETS keepassxc-autotype-windows
BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)
2 changes: 1 addition & 1 deletion src/autotype/xcb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include_directories(SYSTEM ${X11_X11_INCLUDE_PATH})
set(autotype_XCB_SOURCES AutoTypeXCB.cpp)

add_library(keepassxc-autotype-xcb MODULE ${autotype_XCB_SOURCES})
target_link_libraries(keepassxc-autotype-xcb keepassxc_gui Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
target_link_libraries(keepassxc-autotype-xcb keepassxc_gui Qt6::Core Qt6::Widgets Qt6::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
install(TARGETS keepassxc-autotype-xcb
BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)
6 changes: 3 additions & 3 deletions src/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 KeePassXC Team <[email protected]>
# Copyright (C) 2025 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 @@ -40,6 +40,6 @@ if(WITH_XC_BROWSER)
PasskeyUtils.cpp)
endif()

add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES})
target_link_libraries(keepassxcbrowser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network ${BOTAN_LIBRARIES})
add_library(browser STATIC ${browser_SOURCES})
target_link_libraries(browser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network ${BOTAN_LIBRARIES})
endif()
5 changes: 2 additions & 3 deletions src/core/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,11 +1047,11 @@ QString Entry::resolveMultiplePlaceholdersRecursive(const QString& str, int maxD
int capEnd = 0;
while (matches.hasNext()) {
const auto match = matches.next();
result += str.midRef(capEnd, match.capturedStart() - capEnd);
result += QStringView{str}.mid(capEnd, match.capturedStart() - capEnd);
result += resolvePlaceholderRecursive(match.captured(), maxDepth);
capEnd = match.capturedEnd();
}
result += str.rightRef(str.length() - capEnd);
result += QStringView{str}.right(str.length() - capEnd);
return result;
}

Expand Down Expand Up @@ -1530,7 +1530,6 @@ QString Entry::resolveUrl(const QString& url) const
} else if (url.startsWith("cmd://")) {
QStringList cmdList = newUrl.split(" ");
for (int i = 1; i < cmdList.size(); ++i) {
QString& cmd = cmdList[i];
// Don't pass arguments to the resolveUrl function (they look like URL's)
if (!cmdList[i].startsWith("-") && !cmdList[i].startsWith("/")) {
return resolveUrl(cmdList[i].remove(QRegularExpression("'|\"")));
Expand Down
5 changes: 0 additions & 5 deletions src/core/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
#include "config-keepassx.h"

#include "core/Config.h"

#ifdef WITH_XC_KEESHARE
#include "keeshare/KeeShare.h"
#endif

#include "core/Global.h"
#include "core/Metadata.h"
#include "core/Tools.h"
Expand Down
2 changes: 0 additions & 2 deletions src/core/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
#include "Metadata.h"

#include "core/Clock.h"
#include "core/Entry.h"
#include "core/Group.h"

#include <QApplication>
#include <QCryptographicHash>
#include <QJsonDocument>

Expand Down
3 changes: 1 addition & 2 deletions src/core/PassphraseGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ void PassphraseGenerator::setWordList(const QString& path)
}

QTextStream in(&file);
in.setCodec("UTF-8");
QString line = in.readLine();
bool isSigned = line.startsWith("-----BEGIN PGP SIGNED MESSAGE-----");
if (isSigned) {
Expand All @@ -99,7 +98,7 @@ void PassphraseGenerator::setWordList(const QString& path)
line = in.readLine();
}

m_wordlist = wordset.toList();
m_wordlist = wordset.values();

if (m_wordlist.size() < m_minimum_wordlist_length) {
qWarning("Wordlist is less than minimum acceptable size: %s", qPrintable(path));
Expand Down
2 changes: 0 additions & 2 deletions src/core/Tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include <QIODevice>
#include <QLocale>
#include <QMetaProperty>
#include <QNetworkCookie>
#include <QNetworkCookieJar>
#include <QRegularExpression>
#include <QStringList>
#include <QUrl>
Expand Down
2 changes: 1 addition & 1 deletion src/fdosecrets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ if(WITH_XC_FDOSECRETS)
objects/Prompt.cpp
dbus/DBusTypes.cpp
)
target_link_libraries(fdosecrets Qt5::Core Qt5::Widgets Qt5::DBus ${BOTAN_LIBRARIES})
target_link_libraries(fdosecrets Qt6::Core Qt6::Widgets Qt6::DBus ${BOTAN_LIBRARIES})
endif()
7 changes: 5 additions & 2 deletions src/format/BitwardenReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ namespace
// Change from UUID to base64 byte array
const auto credentialIdValue = passkey.value("credentialId").toString();
if (!credentialIdValue.isEmpty()) {
const auto credentialUuid = Tools::uuidToHex(credentialIdValue);
const auto credentialIdArray = QByteArray::fromHex(credentialUuid.toUtf8());
const auto uuid = Tools::hexToUuid(credentialIdValue);
// What?
//const auto credentialUuid = Tools::uuidToHex(credentialIdValue);
//const auto credentialIdArray = QByteArray::fromHex(credentialUuid.toUtf8());
const auto credentialIdArray = QByteArray::fromHex(uuid.toByteArray());
const auto credentialId =
credentialIdArray.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
entry->attributes()->set(EntryAttributes::KPEX_PASSKEY_CREDENTIAL_ID, credentialId, true);
Expand Down
2 changes: 1 addition & 1 deletion src/format/CsvParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "CsvParser.h"

#include <QFile>
#include <QTextCodec>
//#include <QTextCodec>

#include "core/Tools.h"

Expand Down
2 changes: 1 addition & 1 deletion src/format/KeePass1Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <QFile>
#include <QFileInfo>
#include <QRegularExpression>
#include <QTextCodec>
#include <QtCore5Compat/QTextCodec>

#include "core/Endian.h"
#include "core/Group.h"
Expand Down
Loading

0 comments on commit e04319d

Please sign in to comment.