Refactor: separate GUI sources from core sources

This PR splits the GUI source files from the core source files. The immediate goal is to allow the CLI to require only a minimum number of dynamic libraries. The long term goal is to create an architectural boundary around the core module, in preparation of libkdbx.
This commit is contained in:
louib 2022-09-17 21:45:43 -04:00 committed by Jonathan White
parent 854459068f
commit 166a371050
36 changed files with 173 additions and 163 deletions

View File

@ -16,7 +16,19 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(keepassx_SOURCES add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser")
add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration")
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking")
if(UNIX AND NOT APPLE)
add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.")
endif()
set(core_SOURCES
core/Alloc.cpp core/Alloc.cpp
core/AutoTypeAssociations.cpp core/AutoTypeAssociations.cpp
core/Base32.cpp core/Base32.cpp
@ -47,7 +59,6 @@ set(keepassx_SOURCES
core/Tools.cpp core/Tools.cpp
core/Totp.cpp core/Totp.cpp
core/Translator.cpp core/Translator.cpp
core/UrlTools.cpp
cli/Utils.cpp cli/Utils.cpp
cli/TextStream.cpp cli/TextStream.cpp
crypto/Crypto.cpp crypto/Crypto.cpp
@ -79,6 +90,18 @@ set(keepassx_SOURCES
format/OpVaultReaderAttachments.cpp format/OpVaultReaderAttachments.cpp
format/OpVaultReaderBandEntry.cpp format/OpVaultReaderBandEntry.cpp
format/OpVaultReaderSections.cpp format/OpVaultReaderSections.cpp
keys/CompositeKey.cpp
keys/FileKey.cpp
keys/PasswordKey.cpp
keys/ChallengeResponseKey.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/StoreDataStream.cpp
streams/SymmetricCipherStream.cpp)
set(gui_SOURCES
gui/styles/styles.qrc gui/styles/styles.qrc
gui/styles/StateColorPalette.cpp gui/styles/StateColorPalette.cpp
gui/styles/base/phantomcolor.cpp gui/styles/base/phantomcolor.cpp
@ -124,6 +147,7 @@ set(keepassx_SOURCES
gui/TotpExportSettingsDialog.cpp gui/TotpExportSettingsDialog.cpp
gui/DatabaseOpenDialog.cpp gui/DatabaseOpenDialog.cpp
gui/URLEdit.cpp gui/URLEdit.cpp
gui/UrlTools.cpp
gui/WelcomeWidget.cpp gui/WelcomeWidget.cpp
gui/csvImport/CsvImportWidget.cpp gui/csvImport/CsvImportWidget.cpp
gui/csvImport/CsvParserModel.cpp gui/csvImport/CsvParserModel.cpp
@ -180,42 +204,37 @@ set(keepassx_SOURCES
gui/wizard/NewDatabaseWizardPageMetaData.cpp gui/wizard/NewDatabaseWizardPageMetaData.cpp
gui/wizard/NewDatabaseWizardPageEncryption.cpp gui/wizard/NewDatabaseWizardPageEncryption.cpp
gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp gui/wizard/NewDatabaseWizardPageDatabaseKey.cpp
keys/CompositeKey.cpp quickunlock/QuickUnlockInterface.cpp
keys/FileKey.cpp ../share/icons/icons.qrc
keys/PasswordKey.cpp ../share/wizard/wizard.qrc)
keys/ChallengeResponseKey.cpp
streams/HashedBlockStream.cpp
streams/HmacBlockStream.cpp
streams/LayeredStream.cpp
streams/qtiocompressor.cpp
streams/StoreDataStream.cpp
streams/SymmetricCipherStream.cpp
quickunlock/QuickUnlockInterface.cpp)
if(APPLE) if(APPLE)
set(keepassx_SOURCES list(APPEND gui_SOURCES
${keepassx_SOURCES} gui/osutils/macutils/MacPasteboard.cpp
core/MacPasteboard.cpp
gui/osutils/macutils/MacUtils.cpp gui/osutils/macutils/MacUtils.cpp
gui/osutils/macutils/ScreenLockListenerMac.cpp gui/osutils/macutils/ScreenLockListenerMac.cpp
gui/osutils/macutils/AppKitImpl.mm gui/osutils/macutils/AppKitImpl.mm
gui/osutils/macutils/AppKit.h) gui/osutils/macutils/AppKit.h
quickunlock/TouchID.mm)
# TODO: Remove -Wno-error once deprecation warnings have been resolved.
set_source_files_properties(quickunlock/TouchID.mm PROPERTY COMPILE_FLAGS "-Wno-old-style-cast")
endif() endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
set(keepassx_SOURCES list(APPEND gui_SOURCES
${keepassx_SOURCES}
gui/osutils/nixutils/ScreenLockListenerDBus.cpp gui/osutils/nixutils/ScreenLockListenerDBus.cpp
gui/osutils/nixutils/NixUtils.cpp) gui/osutils/nixutils/NixUtils.cpp)
if("${CMAKE_SYSTEM}" MATCHES "Linux") if("${CMAKE_SYSTEM}" MATCHES "Linux")
set(keepassx_SOURCES list(APPEND core_SOURCES
${keepassx_SOURCES}
quickunlock/Polkit.cpp quickunlock/Polkit.cpp
quickunlock/PolkitDbusTypes.cpp) quickunlock/PolkitDbusTypes.cpp)
endif() endif()
if(WITH_XC_X11) if(WITH_XC_X11)
list(APPEND keepassx_SOURCES list(APPEND gui_SOURCES
gui/osutils/nixutils/X11Funcs.cpp) gui/osutils/nixutils/X11Funcs.cpp)
endif() endif()
qt5_add_dbus_adaptor(keepassx_SOURCES qt5_add_dbus_adaptor(gui_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h gui/MainWindow.h
MainWindow) MainWindow)
@ -225,7 +244,7 @@ if(UNIX AND NOT APPLE)
PROPERTIES PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h" INCLUDE "quickunlock/PolkitDbusTypes.h"
) )
qt5_add_dbus_interface(keepassx_SOURCES qt5_add_dbus_interface(core_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus polkit_dbus
) )
@ -235,50 +254,33 @@ if(UNIX AND NOT APPLE)
message(FATAL_ERROR "Could not find libkeyutils") message(FATAL_ERROR "Could not find libkeyutils")
endif() endif()
endif() endif()
if(WIN32) if(WIN32)
set(keepassx_SOURCES list(APPEND gui_SOURCES
${keepassx_SOURCES}
gui/osutils/winutils/ScreenLockListenerWin.cpp gui/osutils/winutils/ScreenLockListenerWin.cpp
gui/osutils/winutils/WinUtils.cpp) gui/osutils/winutils/WinUtils.cpp
../share/windows/icon.rc)
if (MSVC) if (MSVC)
list(APPEND keepassx_SOURCES quickunlock/WindowsHello.cpp) list(APPEND gui_SOURCES quickunlock/WindowsHello.cpp)
endif() endif()
endif() endif()
if(WITH_XC_YUBIKEY) if(WITH_XC_YUBIKEY)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/DeviceListener.cpp) list(APPEND gui_SOURCES gui/osutils/DeviceListener.cpp)
if(APPLE) if(APPLE)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/macutils/DeviceListenerMac.cpp) list(APPEND gui_SOURCES gui/osutils/macutils/DeviceListenerMac.cpp)
elseif(UNIX) elseif(UNIX)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/nixutils/DeviceListenerLibUsb.cpp) list(APPEND gui_SOURCES gui/osutils/nixutils/DeviceListenerLibUsb.cpp)
elseif(WIN32) elseif(WIN32)
set(keepassx_SOURCES ${keepassx_SOURCES} gui/osutils/winutils/DeviceListenerWin.cpp) list(APPEND gui_SOURCES gui/osutils/winutils/DeviceListenerWin.cpp)
endif() endif()
endif() endif()
set(keepassx_SOURCES ${keepassx_SOURCES}
../share/icons/icons.qrc
../share/wizard/wizard.qrc)
set(keepassx_SOURCES_MAINEXE main.cpp)
add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")
add_feature_info(Networking WITH_XC_NETWORKING "Compile KeePassXC with network access code (e.g. for downloading website icons)")
add_feature_info(KeePassXC-Browser WITH_XC_BROWSER "Browser integration with KeePassXC-Browser")
add_feature_info(Passkeys WITH_XC_BROWSER_PASSKEYS "Passkeys support for browser integration")
add_feature_info(SSHAgent WITH_XC_SSHAGENT "SSH agent integration compatible with KeeAgent")
add_feature_info(KeeShare WITH_XC_KEESHARE "Sharing integration with KeeShare")
add_feature_info(YubiKey WITH_XC_YUBIKEY "YubiKey HMAC-SHA1 challenge-response")
add_feature_info(UpdateCheck WITH_XC_UPDATECHECK "Automatic update checking")
if(UNIX AND NOT APPLE)
add_feature_info(FdoSecrets WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API.")
endif()
add_subdirectory(browser) add_subdirectory(browser)
add_subdirectory(proxy) add_subdirectory(proxy)
if(WITH_XC_BROWSER) if(WITH_XC_BROWSER)
set(keepassxcbrowser_LIB keepassxcbrowser) set(browser_LIB browser)
set(keepassx_SOURCES ${keepassx_SOURCES} list(APPEND gui_SOURCES
gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp gui/dbsettings/DatabaseSettingsWidgetBrowser.cpp
gui/entry/EntryURLModel.cpp gui/entry/EntryURLModel.cpp
gui/reports/ReportsWidgetBrowserStatistics.cpp gui/reports/ReportsWidgetBrowserStatistics.cpp
@ -286,7 +288,7 @@ if(WITH_XC_BROWSER)
endif() endif()
if(WITH_XC_BROWSER_PASSKEYS) if(WITH_XC_BROWSER_PASSKEYS)
set(keepassx_SOURCES ${keepassx_SOURCES} list(APPEND gui_SOURCES
gui/reports/ReportsWidgetPasskeys.cpp gui/reports/ReportsWidgetPasskeys.cpp
gui/reports/ReportsPagePasskeys.cpp gui/reports/ReportsPagePasskeys.cpp
gui/passkeys/PasskeyExporter.cpp gui/passkeys/PasskeyExporter.cpp
@ -318,7 +320,6 @@ endif()
add_subdirectory(thirdparty) add_subdirectory(thirdparty)
set(autotype_SOURCES set(autotype_SOURCES
core/Tools.cpp
autotype/AutoType.cpp autotype/AutoType.cpp
autotype/AutoTypeAction.cpp autotype/AutoTypeAction.cpp
autotype/AutoTypeMatchModel.cpp autotype/AutoTypeMatchModel.cpp
@ -327,57 +328,42 @@ set(autotype_SOURCES
autotype/PickcharsDialog.cpp autotype/PickcharsDialog.cpp
autotype/WindowSelectComboBox.cpp) autotype/WindowSelectComboBox.cpp)
if(WIN32) add_library(autotype STATIC ${autotype_SOURCES})
set(keepassx_SOURCES_MAINEXE ${keepassx_SOURCES_MAINEXE} ${CMAKE_SOURCE_DIR}/share/windows/icon.rc) target_link_libraries(autotype Qt5::Core Qt5::Widgets)
endif()
if(WITH_XC_YUBIKEY) if(WITH_XC_YUBIKEY)
list(APPEND keepassx_SOURCES list(APPEND core_SOURCES
keys/drivers/YubiKey.h keys/drivers/YubiKey.h
keys/drivers/YubiKey.cpp keys/drivers/YubiKey.cpp
keys/drivers/YubiKeyInterface.cpp keys/drivers/YubiKeyInterface.cpp
keys/drivers/YubiKeyInterfaceUSB.cpp keys/drivers/YubiKeyInterfaceUSB.cpp
keys/drivers/YubiKeyInterfacePCSC.cpp) keys/drivers/YubiKeyInterfacePCSC.cpp)
else() else()
list(APPEND keepassx_SOURCES list(APPEND core_SOURCES
keys/drivers/YubiKey.h keys/drivers/YubiKey.h
keys/drivers/YubiKeyStub.cpp) keys/drivers/YubiKeyStub.cpp)
endif() endif()
if(WITH_XC_NETWORKING) if(WITH_XC_NETWORKING)
list(APPEND keepassx_SOURCES list(APPEND gui_SOURCES
core/HibpDownloader.cpp networking/HibpDownloader.cpp
core/NetworkManager.cpp networking/NetworkManager.cpp
networking/UpdateChecker.cpp
gui/UpdateCheckDialog.cpp gui/UpdateCheckDialog.cpp
gui/IconDownloader.cpp gui/IconDownloader.cpp
gui/IconDownloaderDialog.cpp gui/IconDownloaderDialog.cpp)
updatecheck/UpdateChecker.cpp)
endif()
if(APPLE)
list(APPEND keepassx_SOURCES quickunlock/TouchID.mm)
# TODO: Remove -Wno-error once deprecation warnings have been resolved.
set_source_files_properties(quickunlock/TouchID.mm PROPERTY COMPILE_FLAGS "-Wno-old-style-cast")
endif() endif()
configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepassx.h) 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) configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h)
add_library(autotype STATIC ${autotype_SOURCES}) # Core Library Definition
target_link_libraries(autotype Qt5::Core Qt5::Widgets) add_library(keepassxc_core STATIC ${core_SOURCES})
set_target_properties(keepassxc_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
add_library(keepassx_core STATIC ${keepassx_SOURCES}) target_link_libraries(keepassxc_core
set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
target_link_libraries(keepassx_core
autotype
${keepassxcbrowser_LIB}
${qrcode_LIB} ${qrcode_LIB}
${fdosecrets_LIB}
Qt5::Core Qt5::Core
Qt5::Concurrent Qt5::Concurrent
Qt5::Network
Qt5::Widgets
${BOTAN_LIBRARIES} ${BOTAN_LIBRARIES}
${PCSC_LIBRARIES} ${PCSC_LIBRARIES}
${ZXCVBN_LIBRARIES} ${ZXCVBN_LIBRARIES}
@ -385,39 +371,45 @@ target_link_libraries(keepassx_core
${MINIZIP_LIBRARIES} ${MINIZIP_LIBRARIES}
${ARGON2_LIBRARIES} ${ARGON2_LIBRARIES}
${KEYUTILS_LIBRARIES} ${KEYUTILS_LIBRARIES}
${thirdparty_LIBRARIES} ${thirdparty_LIBRARIES})
)
if(WITH_XC_SSHAGENT) # GUI Library Definition
target_link_libraries(keepassx_core sshagent) add_library(keepassxc_gui STATIC ${gui_SOURCES})
endif() set_target_properties(keepassxc_gui PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE)
if(WITH_XC_KEESHARE) target_link_libraries(keepassxc_gui
target_link_libraries(keepassx_core keeshare) keepassxc_core
endif() Qt5::Network
Qt5::Widgets
autotype
${browser_LIB}
${fdosecrets_LIB}
${keeshare_LIB}
${sshagent_LIB})
if(APPLE) if(APPLE)
target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication") target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication")
if(Qt5MacExtras_FOUND) if(Qt5MacExtras_FOUND)
target_link_libraries(keepassx_core Qt5::MacExtras) target_link_libraries(keepassxc_gui Qt5::MacExtras)
endif() endif()
endif() endif()
if(HAIKU) if(HAIKU)
target_link_libraries(keepassx_core network) target_link_libraries(keepassxc_gui network)
endif() endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus ${LIBUSB_LIBRARIES}) target_link_libraries(keepassxc_core Qt5::DBus ${LIBUSB_LIBRARIES})
if(WITH_XC_X11) if(WITH_XC_X11)
target_link_libraries(keepassx_core Qt5::X11Extras X11) target_link_libraries(keepassxc_gui Qt5::X11Extras X11)
endif() endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS}) include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
endif() endif()
if(WIN32) if(WIN32)
target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib) target_link_libraries(keepassxc_gui Wtsapi32.lib Ws2_32.lib)
if (MSVC) if (MSVC)
target_link_libraries(keepassx_core WindowsApp.lib) target_link_libraries(keepassxc_gui WindowsApp.lib)
endif() endif()
endif() endif()
# Main Executable Defintion
if(WIN32) if(WIN32)
include(GenerateProductVersion) include(GenerateProductVersion)
generate_product_version( generate_product_version(
@ -430,11 +422,11 @@ if(WIN32)
) )
endif() endif()
add_executable(${PROGNAME} WIN32 ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles}) add_executable(${PROGNAME} WIN32 main.cpp ${WIN32_ProductVersionFiles})
target_link_libraries(${PROGNAME} keepassx_core) target_link_libraries(${PROGNAME} keepassxc_gui)
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON) set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
# macOS App Bundle
if(APPLE AND WITH_APP_BUNDLE) if(APPLE AND WITH_APP_BUNDLE)
install(FILES ${CMAKE_SOURCE_DIR}/share/macosx/embedded.provisionprofile DESTINATION ${BUNDLE_INSTALL_DIR}) install(FILES ${CMAKE_SOURCE_DIR}/share/macosx/embedded.provisionprofile DESTINATION ${BUNDLE_INSTALL_DIR})
configure_file(${CMAKE_SOURCE_DIR}/share/macosx/Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) configure_file(${CMAKE_SOURCE_DIR}/share/macosx/Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
@ -463,6 +455,7 @@ install(TARGETS ${PROGNAME}
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime) RUNTIME DESTINATION ${BIN_INSTALL_DIR} COMPONENT Runtime)
# Windows Installer Definition
if(WIN32) if(WIN32)
if(${CMAKE_SIZEOF_VOID_P} EQUAL "8") if(${CMAKE_SIZEOF_VOID_P} EQUAL "8")
set(OUTPUT_FILE_POSTFIX "Win64") set(OUTPUT_FILE_POSTFIX "Win64")

View File

@ -1,4 +1,4 @@
set(autotype_test_SOURCES AutoTypeTest.cpp) set(autotype_test_SOURCES AutoTypeTest.cpp)
add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES}) add_library(keepassxc-autotype-test MODULE ${autotype_test_SOURCES})
target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets) target_link_libraries(keepassxc-autotype-test keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)

View File

@ -1,7 +1,7 @@
set(autotype_win_SOURCES AutoTypeWindows.cpp) set(autotype_win_SOURCES AutoTypeWindows.cpp)
add_library(keepassxc-autotype-windows MODULE ${autotype_win_SOURCES}) add_library(keepassxc-autotype-windows MODULE ${autotype_win_SOURCES})
target_link_libraries(keepassxc-autotype-windows keepassx_core ${autotype_LIB} Qt5::Core Qt5::Widgets) target_link_libraries(keepassxc-autotype-windows keepassxc_gui ${autotype_LIB} Qt5::Core Qt5::Widgets)
install(TARGETS keepassxc-autotype-windows install(TARGETS keepassxc-autotype-windows
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime) LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)

View File

@ -3,7 +3,7 @@ include_directories(SYSTEM ${X11_X11_INCLUDE_PATH})
set(autotype_XCB_SOURCES AutoTypeXCB.cpp) set(autotype_XCB_SOURCES AutoTypeXCB.cpp)
add_library(keepassxc-autotype-xcb MODULE ${autotype_XCB_SOURCES}) add_library(keepassxc-autotype-xcb MODULE ${autotype_XCB_SOURCES})
target_link_libraries(keepassxc-autotype-xcb keepassx_core Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB}) target_link_libraries(keepassxc-autotype-xcb keepassxc_gui Qt5::Core Qt5::Widgets Qt5::X11Extras ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB})
install(TARGETS keepassxc-autotype-xcb install(TARGETS keepassxc-autotype-xcb
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime) LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)

View File

@ -25,9 +25,9 @@
#include "BrowserMessageBuilder.h" #include "BrowserMessageBuilder.h"
#include "BrowserSettings.h" #include "BrowserSettings.h"
#include "core/Tools.h" #include "core/Tools.h"
#include "core/UrlTools.h"
#include "gui/MainWindow.h" #include "gui/MainWindow.h"
#include "gui/MessageBox.h" #include "gui/MessageBox.h"
#include "gui/UrlTools.h"
#include "gui/osutils/OSUtils.h" #include "gui/osutils/OSUtils.h"
#ifdef WITH_XC_BROWSER_PASSKEYS #ifdef WITH_XC_BROWSER_PASSKEYS
#include "BrowserPasskeys.h" #include "BrowserPasskeys.h"

View File

@ -16,7 +16,7 @@
if(WITH_XC_BROWSER) if(WITH_XC_BROWSER)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(keepassxcbrowser_SOURCES set(browser_SOURCES
BrowserAccessControlDialog.cpp BrowserAccessControlDialog.cpp
BrowserAction.cpp BrowserAction.cpp
BrowserEntryConfig.cpp BrowserEntryConfig.cpp
@ -32,7 +32,7 @@ if(WITH_XC_BROWSER)
NativeMessageInstaller.cpp) NativeMessageInstaller.cpp)
if(WITH_XC_BROWSER_PASSKEYS) if(WITH_XC_BROWSER_PASSKEYS)
list(APPEND keepassxcbrowser_SOURCES list(APPEND browser_SOURCES
BrowserCbor.cpp BrowserCbor.cpp
BrowserPasskeys.cpp BrowserPasskeys.cpp
BrowserPasskeysClient.cpp BrowserPasskeysClient.cpp
@ -40,6 +40,6 @@ if(WITH_XC_BROWSER)
PasskeyUtils.cpp) PasskeyUtils.cpp)
endif() endif()
add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES}) add_library(browser STATIC ${browser_SOURCES})
target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES}) target_link_libraries(browser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES})
endif() endif()

View File

@ -19,7 +19,7 @@
#include "BrowserMessageBuilder.h" #include "BrowserMessageBuilder.h"
#include "BrowserPasskeys.h" #include "BrowserPasskeys.h"
#include "core/Tools.h" #include "core/Tools.h"
#include "core/UrlTools.h" #include "gui/UrlTools.h"
#include <QList> #include <QList>
#include <QUrl> #include <QUrl>

View File

@ -58,7 +58,7 @@ add_executable(keepassxc-cli keepassxc-cli.cpp)
target_link_libraries(keepassxc-cli target_link_libraries(keepassxc-cli
${GPGERROR_LIBRARIES} ${GPGERROR_LIBRARIES}
cli cli
keepassx_core) keepassxc_core)
install(TARGETS keepassxc-cli install(TARGETS keepassxc-cli
BUNDLE DESTINATION . COMPONENT Runtime BUNDLE DESTINATION . COMPONENT Runtime

View File

@ -802,10 +802,21 @@ void Entry::addHistoryItem(Entry* entry)
{ {
Q_ASSERT(!entry->parent()); Q_ASSERT(!entry->parent());
entry->setHistoryOwner(this);
m_history.append(entry); m_history.append(entry);
emitModified(); emitModified();
} }
void Entry::setHistoryOwner(Entry* entry)
{
m_historyOwner = entry;
}
Entry* Entry::historyOwner() const
{
return m_historyOwner;
}
void Entry::removeHistoryItems(const QList<Entry*>& historyEntries) void Entry::removeHistoryItems(const QList<Entry*>& historyEntries)
{ {
if (historyEntries.isEmpty()) { if (historyEntries.isEmpty()) {

View File

@ -168,6 +168,8 @@ public:
QList<Entry*> historyItems(); QList<Entry*> historyItems();
const QList<Entry*>& historyItems() const; const QList<Entry*>& historyItems() const;
void addHistoryItem(Entry* entry); void addHistoryItem(Entry* entry);
void setHistoryOwner(Entry* entry);
Entry* historyOwner() const;
void removeHistoryItems(const QList<Entry*>& historyEntries); void removeHistoryItems(const QList<Entry*>& historyEntries);
void truncateHistory(); void truncateHistory();
@ -294,6 +296,7 @@ private:
QPointer<AutoTypeAssociations> m_autoTypeAssociations; QPointer<AutoTypeAssociations> m_autoTypeAssociations;
QPointer<CustomData> m_customData; QPointer<CustomData> m_customData;
QList<Entry*> m_history; // Items sorted from oldest to newest QList<Entry*> m_history; // Items sorted from oldest to newest
QPointer<Entry> m_historyOwner;
QScopedPointer<Entry> m_tmpHistoryItem; QScopedPointer<Entry> m_tmpHistoryItem;
bool m_modifiedSinceBegin; bool m_modifiedSinceBegin;

View File

@ -247,6 +247,20 @@ bool Group::isEmpty() const
return !hasChildren() && m_entries.isEmpty(); return !hasChildren() && m_entries.isEmpty();
} }
// TODO: Refactor this when KeeShare is refactored
bool Group::isShared() const
{
auto group = this;
do {
if (group->customData()->contains("KeeShare/Reference")) {
return true;
}
group = group->m_parent;
} while (group);
return false;
}
CustomData* Group::customData() CustomData* Group::customData()
{ {
return m_customData; return m_customData;

View File

@ -98,6 +98,7 @@ public:
bool isExpired() const; bool isExpired() const;
bool isRecycled() const; bool isRecycled() const;
bool isEmpty() const; bool isEmpty() const;
bool isShared() const;
CustomData* customData(); CustomData* customData();
const CustomData* customData() const; const CustomData* customData() const;
Group::TriState resolveCustomDataTriState(const QString& key, bool checkParent = true) const; Group::TriState resolveCustomDataTriState(const QString& key, bool checkParent = true) const;

View File

@ -23,10 +23,6 @@
#include "crypto/CryptoHash.h" #include "crypto/CryptoHash.h"
#include "crypto/Random.h" #include "crypto/Random.h"
#include "format/KeePass2RandomStream.h" #include "format/KeePass2RandomStream.h"
#ifdef WITH_XC_KEESHARE
#include "keeshare/KeeShare.h"
#include "keeshare/KeeShareSettings.h"
#endif
#include "streams/HmacBlockStream.h" #include "streams/HmacBlockStream.h"
#include "streams/SymmetricCipherStream.h" #include "streams/SymmetricCipherStream.h"
#include "streams/qtiocompressor.h" #include "streams/qtiocompressor.h"
@ -232,8 +228,12 @@ KdbxXmlWriter::BinaryIdxMap Kdbx4Writer::writeAttachments(QIODevice* device, Dat
#ifdef WITH_XC_KEESHARE #ifdef WITH_XC_KEESHARE
// Namespace KeeShare attachments so they don't get deduplicated together with attachments // Namespace KeeShare attachments so they don't get deduplicated together with attachments
// from other databases. Prevents potential filesize side channels. // from other databases. Prevents potential filesize side channels.
if (auto shared = KeeShare::resolveSharedGroup(entry->group())) { auto group = entry->group();
hash.addData(KeeShare::referenceOf(shared).uuid.toByteArray()); if (!group && entry->historyOwner()) {
group = entry->historyOwner()->group();
}
if (group && group->isShared()) {
hash.addData(group->uuid().toByteArray());
} else { } else {
hash.addData(db->uuid().toByteArray()); hash.addData(db->uuid().toByteArray());
} }

View File

@ -24,8 +24,6 @@
#include "core/Endian.h" #include "core/Endian.h"
#include "crypto/CryptoHash.h" #include "crypto/CryptoHash.h"
#include "format/KeePass2RandomStream.h" #include "format/KeePass2RandomStream.h"
#include "keeshare/KeeShare.h"
#include "keeshare/KeeShareSettings.h"
#include "streams/qtiocompressor.h" #include "streams/qtiocompressor.h"
/** /**
@ -114,8 +112,12 @@ void KdbxXmlWriter::fillBinaryIdxMap()
#ifdef WITH_XC_KEESHARE #ifdef WITH_XC_KEESHARE
// Namespace KeeShare attachments so they don't get deduplicated together with attachments // Namespace KeeShare attachments so they don't get deduplicated together with attachments
// from other databases. Prevents potential filesize side channels. // from other databases. Prevents potential filesize side channels.
if (auto shared = KeeShare::resolveSharedGroup(entry->group())) { auto group = entry->group();
hash.addData(KeeShare::referenceOf(shared).uuid.toByteArray()); if (!group && entry->historyOwner()) {
group = entry->historyOwner()->group();
}
if (group && group->isShared()) {
hash.addData(group->uuid().toByteArray());
} else { } else {
hash.addData(m_db->uuid().toByteArray()); hash.addData(m_db->uuid().toByteArray());
} }

View File

@ -22,7 +22,7 @@
#include <QElapsedTimer> #include <QElapsedTimer>
#include <QObject> #include <QObject>
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
#include "core/MacPasteboard.h" #include "gui/osutils/macutils/MacPasteboard.h"
#include <QPointer> #include <QPointer>
#endif #endif

View File

@ -17,8 +17,8 @@
#include "IconDownloader.h" #include "IconDownloader.h"
#include "core/Config.h" #include "core/Config.h"
#include "core/NetworkManager.h" #include "gui/UrlTools.h"
#include "core/UrlTools.h" #include "networking/NetworkManager.h"
#include <QBuffer> #include <QBuffer>
#include <QHostInfo> #include <QHostInfo>

View File

@ -50,7 +50,7 @@
#ifdef WITH_XC_UPDATECHECK #ifdef WITH_XC_UPDATECHECK
#include "gui/UpdateCheckDialog.h" #include "gui/UpdateCheckDialog.h"
#include "updatecheck/UpdateChecker.h" #include "networking/UpdateChecker.h"
#endif #endif
#ifdef WITH_XC_SSHAGENT #ifdef WITH_XC_SSHAGENT

View File

@ -18,9 +18,8 @@
#include "URLEdit.h" #include "URLEdit.h"
#include "core/Tools.h"
#include "core/UrlTools.h"
#include "gui/Icons.h" #include "gui/Icons.h"
#include "gui/UrlTools.h"
#include "gui/styles/StateColorPalette.h" #include "gui/styles/StateColorPalette.h"
URLEdit::URLEdit(QWidget* parent) URLEdit::URLEdit(QWidget* parent)

View File

@ -22,7 +22,7 @@
#include "config-keepassx.h" #include "config-keepassx.h"
#include "gui/Icons.h" #include "gui/Icons.h"
#include "updatecheck/UpdateChecker.h" #include "networking/UpdateChecker.h"
UpdateCheckDialog::UpdateCheckDialog(QWidget* parent) UpdateCheckDialog::UpdateCheckDialog(QWidget* parent)
: QDialog(parent) : QDialog(parent)

View File

@ -19,10 +19,12 @@
#define KEEPASSXC_URLTOOLS_H #define KEEPASSXC_URLTOOLS_H
#include "config-keepassx.h" #include "config-keepassx.h"
#include <QNetworkReply>
#include <QObject> #include <QObject>
#include <QUrl> #include <QUrl>
#include <QVariant> #include <QVariant>
#if defined(WITH_XC_NETWORKING) || defined(WITH_XC_BROWSER)
#include <QNetworkReply>
#endif
class UrlTools : public QObject class UrlTools : public QObject
{ {

View File

@ -20,8 +20,8 @@
#include "browser/BrowserService.h" #include "browser/BrowserService.h"
#include "core/EntryAttributes.h" #include "core/EntryAttributes.h"
#include "core/UrlTools.h"
#include "gui/Icons.h" #include "gui/Icons.h"
#include "gui/UrlTools.h"
#include "gui/styles/StateColorPalette.h" #include "gui/styles/StateColorPalette.h"
EntryURLModel::EntryURLModel(QObject* parent) EntryURLModel::EntryURLModel(QObject* parent)

View File

@ -24,7 +24,7 @@
#include <QWidget> #include <QWidget>
#ifdef WITH_XC_NETWORKING #ifdef WITH_XC_NETWORKING
#include "core/HibpDownloader.h" #include "networking/HibpDownloader.h"
#endif #endif
class Database; class Database;

View File

@ -16,7 +16,7 @@
*/ */
#include "HibpDownloader.h" #include "HibpDownloader.h"
#include "core/NetworkManager.h" #include "NetworkManager.h"
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QNetworkReply> #include <QNetworkReply>

View File

@ -17,10 +17,10 @@
#include "UpdateChecker.h" #include "UpdateChecker.h"
#include "NetworkManager.h"
#include "config-keepassx.h" #include "config-keepassx.h"
#include "core/Clock.h" #include "core/Clock.h"
#include "core/Config.h" #include "core/Config.h"
#include "core/NetworkManager.h"
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>

View File

@ -40,5 +40,5 @@ elseif(UNIX AND NOT APPLE)
target_compile_definitions(ykcore PRIVATE _GNU_SOURCE) target_compile_definitions(ykcore PRIVATE _GNU_SOURCE)
elseif(APPLE) elseif(APPLE)
target_sources(ykcore PRIVATE ykcore_osx.c) target_sources(ykcore PRIVATE ykcore_osx.c)
target_link_libraries(ykcore PUBLIC "-framework IOKit") target_link_libraries(ykcore PUBLIC "-framework IOKit -framework Foundation")
endif() endif()

View File

@ -90,7 +90,7 @@ macro(add_unit_test)
endif() endif()
endmacro(add_unit_test) endmacro(add_unit_test)
set(TEST_LIBRARIES keepassx_core Qt5::Test) set(TEST_LIBRARIES keepassxc_gui Qt5::Test)
set(testsupport_SOURCES set(testsupport_SOURCES
modeltest.cpp modeltest.cpp
@ -143,7 +143,7 @@ add_unit_test(NAME testkeepass1reader SOURCES TestKeePass1Reader.cpp
LIBS ${TEST_LIBRARIES}) LIBS ${TEST_LIBRARIES})
add_unit_test(NAME testimports SOURCES TestImports.cpp add_unit_test(NAME testimports SOURCES TestImports.cpp
LIBS ${TEST_LIBRARIES}) LIBS ${TEST_LIBRARIES})
if(WITH_XC_NETWORKING) if(WITH_XC_NETWORKING)
add_unit_test(NAME testupdatecheck SOURCES TestUpdateCheck.cpp add_unit_test(NAME testupdatecheck SOURCES TestUpdateCheck.cpp
@ -163,7 +163,7 @@ if(WITH_XC_SSHAGENT)
LIBS sshagent ${TEST_LIBRARIES}) LIBS sshagent ${TEST_LIBRARIES})
if(NOT WIN32) if(NOT WIN32)
add_unit_test(NAME testsshagent SOURCES TestSSHAgent.cpp add_unit_test(NAME testsshagent SOURCES TestSSHAgent.cpp
LIBS ${TEST_LIBRARIES}) LIBS sshagent ${TEST_LIBRARIES})
endif() endif()
endif() endif()
@ -195,7 +195,7 @@ add_unit_test(NAME testcsvparser SOURCES TestCsvParser.cpp
LIBS ${TEST_LIBRARIES}) LIBS ${TEST_LIBRARIES})
add_unit_test(NAME testrandomgenerator SOURCES TestRandomGenerator.cpp add_unit_test(NAME testrandomgenerator SOURCES TestRandomGenerator.cpp
LIBS testsupport ${TEST_LIBRARIES}) LIBS testsupport ${TEST_LIBRARIES})
add_unit_test(NAME testentrysearcher SOURCES TestEntrySearcher.cpp add_unit_test(NAME testentrysearcher SOURCES TestEntrySearcher.cpp
LIBS ${TEST_LIBRARIES}) LIBS ${TEST_LIBRARIES})
@ -225,22 +225,16 @@ add_unit_test(NAME testconfig SOURCES TestConfig.cpp
if(WITH_XC_FDOSECRETS) if(WITH_XC_FDOSECRETS)
add_unit_test(NAME testfdosecrets SOURCES TestFdoSecrets.cpp add_unit_test(NAME testfdosecrets SOURCES TestFdoSecrets.cpp
LIBS testsupport ${TEST_LIBRARIES}) LIBS testsupport fdosecrets ${TEST_LIBRARIES})
endif() endif()
if(WITH_XC_BROWSER) if(WITH_XC_BROWSER)
add_unit_test(NAME testbrowser SOURCES TestBrowser.cpp add_unit_test(NAME testbrowser SOURCES TestBrowser.cpp
LIBS ${TEST_LIBRARIES}) LIBS browser ${TEST_LIBRARIES})
if(WITH_XC_BROWSER_PASSKEYS) if(WITH_XC_BROWSER_PASSKEYS)
# Prevent duplicate linking with macOS add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
if(APPLE) LIBS browser ${TEST_LIBRARIES})
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
LIBS ${TEST_LIBRARIES})
else()
add_unit_test(NAME testpasskeys SOURCES TestPasskeys.cpp
LIBS keepassxcbrowser ${TEST_LIBRARIES})
endif()
endif() endif()
endif() endif()

View File

@ -24,10 +24,6 @@
#include "format/KeePass2.h" #include "format/KeePass2.h"
#include "format/KeePass2Reader.h" #include "format/KeePass2Reader.h"
#include "format/KeePass2Writer.h" #include "format/KeePass2Writer.h"
#ifdef WITH_XC_KEESHARE
#include "keeshare/KeeShare.h"
#include "keeshare/KeeShareSettings.h"
#endif
#include "keys/FileKey.h" #include "keys/FileKey.h"
#include "keys/PasswordKey.h" #include "keys/PasswordKey.h"
#include "mock/MockChallengeResponseKey.h" #include "mock/MockChallengeResponseKey.h"
@ -441,13 +437,8 @@ void TestKdbx4Format::testAttachmentIndexStability()
group2->setUuid(QUuid::createUuid()); group2->setUuid(QUuid::createUuid());
QVERIFY(!group2->uuid().isNull()); QVERIFY(!group2->uuid().isNull());
group2->setParent(group1); group2->setParent(group1);
#ifdef WITH_XC_KEESHARE group2->customData()->set("KeeShare/Reference", "value doesn't matter");
KeeShareSettings::Reference ref; QVERIFY(group2->isShared());
ref.type = KeeShareSettings::SynchronizeWith;
ref.path = "123";
KeeShare::setReferenceTo(group2, ref);
QVERIFY(KeeShare::isShared(group2));
#endif
auto attachment1 = QByteArray("qwerty"); auto attachment1 = QByteArray("qwerty");
auto attachment2 = QByteArray("asdf"); auto attachment2 = QByteArray("asdf");
@ -510,9 +501,9 @@ void TestKdbx4Format::testAttachmentIndexStability()
QCOMPARE(a2->value("a"), attachment1); QCOMPARE(a2->value("a"), attachment1);
QCOMPARE(a2->value("b"), attachment2); QCOMPARE(a2->value("b"), attachment2);
#ifdef WITH_XC_KEESHARE auto sharedGroup = db2->rootGroup()->findEntryByUuid(uuid3)->group();
QVERIFY(KeeShare::isShared(db2->rootGroup()->findEntryByUuid(uuid3)->group())); QVERIFY(sharedGroup->isShared());
#endif
auto a3 = db2->rootGroup()->findEntryByUuid(uuid3)->attachments(); auto a3 = db2->rootGroup()->findEntryByUuid(uuid3)->attachments();
QCOMPARE(a3->keys().size(), 4); QCOMPARE(a3->keys().size(), 4);
QCOMPARE(a3->values().size(), 3); QCOMPARE(a3->values().size(), 3);

View File

@ -17,7 +17,7 @@
#include "TestUpdateCheck.h" #include "TestUpdateCheck.h"
#include "crypto/Crypto.h" #include "crypto/Crypto.h"
#include "updatecheck/UpdateChecker.h" #include "networking/UpdateChecker.h"
#include <QTest> #include <QTest>

View File

@ -18,7 +18,7 @@
#ifndef KEEPASSXC_TESTURLTOOLS_H #ifndef KEEPASSXC_TESTURLTOOLS_H
#define KEEPASSXC_TESTURLTOOLS_H #define KEEPASSXC_TESTURLTOOLS_H
#include "core/UrlTools.h" #include "gui/UrlTools.h"
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>