Skip to content

Commit

Permalink
Some changes. Lot TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
varjolintu committed Dec 2, 2023
1 parent 74792c2 commit 3843e83
Show file tree
Hide file tree
Showing 63 changed files with 469 additions and 440 deletions.
50 changes: 19 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2018 KeePassXC Team <[email protected]>
# Copyright (C) 2023 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 @@ -205,6 +205,9 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
check_pie_supported()
endif()

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

# Find Botan early since the version affects subsequent compiler options
find_package(Botan REQUIRED)
if(BOTAN_VERSION VERSION_GREATER_EQUAL "3.0.0")
Expand Down Expand Up @@ -496,37 +499,22 @@ if(UNIX AND NOT APPLE)
if(WITH_XC_X11)
list(APPEND QT_COMPONENTS X11Extras)
endif()
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} DBus REQUIRED)
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} DBus REQUIRED)
elseif(APPLE)
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED HINTS
/usr/local/opt/qt@5/lib/cmake
/usr/local/Cellar/qt@5/*/lib/cmake
/opt/homebrew/opt/qt@5/lib/cmake
ENV PATH)
find_package(Qt5 COMPONENTS MacExtras HINTS
/usr/local/opt/qt@5/lib/cmake
/usr/local/Cellar/qt@5/*/lib/cmake
/opt/homebrew/opt/qt@5/lib/cmake
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} REQUIRED HINTS
/usr/local/opt/qt/lib/cmake
/usr/local/Cellar/qt/*/lib/cmake
/opt/homebrew/opt/qt/lib/cmake
ENV PATH)
else()
find_package(Qt5 COMPONENTS ${QT_COMPONENTS} REQUIRED)
endif()

if(Qt5Core_VERSION VERSION_LESS "5.9.5")
message(FATAL_ERROR "Qt version 5.9.5 or higher is required")
find_package(Qt6 COMPONENTS ${QT_COMPONENTS} REQUIRED)
endif()

# CBOR for Passkeys requires Qt 5.12
if(Qt5Core_VERSION VERSION_LESS "5.12.0")
message(STATUS "Qt version 5.12.0 or higher is required for Passkeys support")
set(WITH_XC_BROWSER_PASSKEYS OFF)
if(Qt6Core_VERSION VERSION_LESS "6.6.0")
message(FATAL_ERROR "Qt version 6.6.0 or higher is required")
endif()

get_filename_component(Qt5_PREFIX ${Qt5_DIR}/../../.. REALPATH)
if(APPLE)
# Add includes under Qt5 Prefix in case Qt6 is also installed
include_directories(SYSTEM ${Qt5_PREFIX}/include)
endif()
get_filename_component(Qt6_PREFIX ${Qt6_DIR}/../../.. REALPATH)

# Process moc automatically
set(CMAKE_AUTOMOC ON)
Expand All @@ -537,18 +525,18 @@ set(CMAKE_AUTORCC ON)

if(APPLE)
set(CMAKE_MACOSX_RPATH TRUE)
find_program(MACDEPLOYQT_EXE macdeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/bin ENV PATH)
find_program(MACDEPLOYQT_EXE macdeployqt6 HINTS ${Qt6_PREFIX}/bin ${Qt6_PREFIX}/tools/qt/bin ENV PATH)
if(NOT MACDEPLOYQT_EXE)
message(FATAL_ERROR "macdeployqt is required to build on macOS")
message(FATAL_ERROR "macdeployqt6 is required to build on macOS")
endif()
message(STATUS "Using macdeployqt: ${MACDEPLOYQT_EXE}")
message(STATUS "Using macdeployqt6: ${MACDEPLOYQT_EXE}")
set(MACDEPLOYQT_EXTRA_BINARIES "")
elseif(WIN32)
find_program(WINDEPLOYQT_EXE windeployqt HINTS ${Qt5_PREFIX}/bin ${Qt5_PREFIX}/tools/qt5/bin ENV PATH)
find_program(WINDEPLOYQT_EXE windeployqt6 HINTS ${Qt6_PREFIX}/bin ${Qt6_PREFIX}/tools/qt/bin ENV PATH)
if(NOT WINDEPLOYQT_EXE)
message(FATAL_ERROR "windeployqt is required to build on Windows")
message(FATAL_ERROR "windeployqt6 is required to build on Windows")
endif()
message(STATUS "Using windeployqt: ${WINDEPLOYQT_EXE}")
message(STATUS "Using windeployq6t: ${WINDEPLOYQT_EXE}")
endif()

# Debian sets the build type to None for package builds.
Expand Down
14 changes: 7 additions & 7 deletions release-tool
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ checkXcodeSetup() {
fi
}

checkQt5LUpdateExists() {
checkQt6LUpdateExists() {
if cmdExists lupdate && ! $(lupdate -version | grep -q "lupdate version 5\."); then
if ! cmdExists lupdate-qt5; then
exitError "Qt Linguist tool (lupdate-qt5) is not installed! Please install using 'apt install qttools5-dev-tools'"
if ! cmdExists lupdate-qt6; then
exitError "Qt Linguist tool (lupdate-qt6) is not installed! Please install using 'apt install qttools6-dev-tools'"
fi
fi
}
Expand All @@ -379,7 +379,7 @@ performChecks() {
logInfo "Validating toolset and repository..."

checkTransifexCommandExists
checkQt5LUpdateExists
checkQt6LUpdateExists
checkGitRepository
checkReleaseDoesNotExist
checkWorkingTreeClean
Expand Down Expand Up @@ -955,7 +955,7 @@ build() {
export MACOSX_DEPLOYMENT_TARGET

logInfo "Configuring build..."
cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="$(uname -m)" \
cmake -G "${CMAKE_GENERATOR}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" ${CMAKE_OPTIONS} "$SRC_DIR"

logInfo "Compiling and packaging sources..."
Expand Down Expand Up @@ -1404,10 +1404,10 @@ i18n() {
exit 1
fi

checkQt5LUpdateExists
checkQt6LUpdateExists

logInfo "Updating source translation file..."
LUPDATE=lupdate-qt5
LUPDATE=lupdate-qt6
if ! command -v $LUPDATE > /dev/null; then
LUPDATE=lupdate
fi
Expand Down
8 changes: 4 additions & 4 deletions share/translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2017 KeePassXC Team <[email protected]>
# Copyright (C) 2023 KeePassXC Team <[email protected]>
# Copyright (C) 2014 Felix Geyer <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -20,15 +20,15 @@ list(REMOVE_ITEM TRANSLATION_FILES keepassxc_en.ts)
list(REMOVE_ITEM TRANSLATION_FILES ${TRANSLATION_EN_ABS})
message(STATUS "Including translations...\n")

qt5_add_translation(QM_FILES ${TRANSLATION_FILES})
qt6_add_translation(QM_FILES ${TRANSLATION_FILES})

if(WIN32)
file(GLOB QTBASE_TRANSLATIONS ${Qt5_PREFIX}/share/qt5/translations/qtbase_*.qm)
file(GLOB QTBASE_TRANSLATIONS ${Qt6_PREFIX}/share/qt/translations/qtbase_*.qm)
elseif(APPLE OR KEEPASSXC_DIST_APPIMAGE)
file(GLOB QTBASE_TRANSLATIONS
/usr/share/qt/translations/qtbase_*.qm
/usr/share/qt5/translations/qtbase_*.qm
${Qt5_PREFIX}/translations/qtbase_*.qm)
${Qt6_PREFIX}/translations/qtbase_*.qm)
endif()
set(QM_FILES ${QM_FILES} ${QTBASE_TRANSLATIONS})

Expand Down
31 changes: 16 additions & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ if(UNIX AND NOT APPLE)
list(APPEND keepassx_SOURCES
gui/osutils/nixutils/X11Funcs.cpp)
endif()
qt5_add_dbus_adaptor(keepassx_SOURCES
qt6_add_dbus_adaptor(keepassx_SOURCES
gui/org.keepassxc.KeePassXC.MainWindow.xml
gui/MainWindow.h
MainWindow)
Expand All @@ -230,7 +230,7 @@ if(UNIX AND NOT APPLE)
PROPERTIES
INCLUDE "quickunlock/PolkitDbusTypes.h"
)
qt5_add_dbus_interface(keepassx_SOURCES
qt6_add_dbus_interface(keepassx_SOURCES
quickunlock/dbus/org.freedesktop.PolicyKit1.Authority.xml
polkit_dbus
)
Expand Down Expand Up @@ -359,20 +359,24 @@ configure_file(config-keepassx.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-keepas
configure_file(git-info.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/git-info.h)

add_library(autotype STATIC ${autotype_SOURCES})
target_link_libraries(autotype Qt5::Core Qt5::Network Qt5::Widgets)
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}
${qrcode_LIB}
${fdosecrets_LIB}
Qt5::Core
Qt5::Concurrent
Qt5::Network
Qt5::Widgets
Qt6::Core
Qt6::Core5Compat
Qt6::Concurrent
Qt6::Network
Qt6::SvgWidgets
Qt6::Widgets
${BOTAN_LIBRARIES}
${PCSC_LIBRARIES}
${ZXCVBN_LIBRARIES}
Expand All @@ -391,19 +395,16 @@ endif()

if(APPLE)
target_link_libraries(keepassx_core "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication")
if(Qt5MacExtras_FOUND)
target_link_libraries(keepassx_core Qt5::MacExtras)
endif()
endif()
if(HAIKU)
target_link_libraries(keepassx_core network)
endif()
if(UNIX AND NOT APPLE)
target_link_libraries(keepassx_core Qt5::DBus)
target_link_libraries(keepassx_core Qt6::DBus)
if(WITH_XC_X11)
target_link_libraries(keepassx_core Qt5::X11Extras X11)
target_link_libraries(keepassx_core Qt6::X11Extras X11)
endif()
include_directories(${Qt5Gui_PRIVATE_INCLUDE_DIRS})
include_directories(${Qt6Gui_PRIVATE_INCLUDE_DIRS})
endif()
if(WIN32)
target_link_libraries(keepassx_core Wtsapi32.lib Ws2_32.lib)
Expand Down Expand Up @@ -523,7 +524,7 @@ if(WIN32)
COMPONENT Runtime)

# Use windeployqt.exe to setup Qt dependencies
if(Qt5Core_VERSION VERSION_LESS "5.14.1")
if(Qt6Core_VERSION VERSION_LESS "6.6.0") # TODO: Check this.
set(WINDEPLOYQT_MODE "--release")
if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
set(WINDEPLOYQT_MODE "--debug")
Expand Down Expand Up @@ -556,7 +557,7 @@ if(WIN32)
endif()

# install CA cert chains
find_file(SSL_CA_BUNDLE ca-bundle.crt PATHS "${Qt5_PREFIX}/ssl/certs")
find_file(SSL_CA_BUNDLE ca-bundle.crt PATHS "${Qt6_PREFIX}/ssl/certs")
if(SSL_CA_BUNDLE)
install(FILES ${SSL_CA_BUNDLE} DESTINATION "ssl/certs")
else()
Expand Down
4 changes: 2 additions & 2 deletions src/autotype/AutoTypeMatch.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 KeePassXC Team <[email protected]>
* Copyright (C) 2023 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 All @@ -18,10 +18,10 @@
#ifndef KPXC_AUTOTYPEMATCH_H
#define KPXC_AUTOTYPEMATCH_H

#include "core/Entry.h"
#include <QPair>
#include <QPointer>

class Entry;
typedef QPair<QPointer<Entry>, QString> AutoTypeMatch;

#endif // KPXC_AUTOTYPEMATCH_H
8 changes: 4 additions & 4 deletions src/autotype/AutoTypeMatchView.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <[email protected]>
* Copyright (C) 2015 David Wu <[email protected]>
* Copyright (C) 2017 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 @@ -38,9 +38,9 @@ class CustomSortFilterProxyModel : public QSortFilterProxyModel
auto index1 = sourceModel()->index(sourceRow, 1, sourceParent);
auto index2 = sourceModel()->index(sourceRow, 2, sourceParent);

return sourceModel()->data(index0).toString().contains(filterRegExp())
|| sourceModel()->data(index1).toString().contains(filterRegExp())
|| sourceModel()->data(index2).toString().contains(filterRegExp());
return sourceModel()->data(index0).toString().contains(filterRegularExpression())
|| sourceModel()->data(index1).toString().contains(filterRegularExpression())
|| sourceModel()->data(index2).toString().contains(filterRegularExpression());
}
};

Expand Down
2 changes: 0 additions & 2 deletions src/autotype/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
if(WITH_XC_AUTOTYPE)
if(UNIX AND NOT APPLE AND NOT HAIKU)
find_package(X11 REQUIRED COMPONENTS Xi XTest)
find_package(Qt5X11Extras 5.2 REQUIRED)
if(PRINT_SUMMARY)
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")
add_feature_info(Qt5X11Extras Qt5X11Extras_FOUND "The Qt5X11Extras library is required for auto-type")
endif()

add_subdirectory(xcb)
Expand Down
8 changes: 4 additions & 4 deletions src/autotype/mac/AutoTypeMac.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2023 KeePassXC Team <[email protected]>
* Copyright (C) 2016 Lennart Glauer <[email protected]>
* Copyright (C) 2017 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 All @@ -23,8 +23,8 @@
#include <QtPlugin>
#include <memory>

#include "autotype/AutoTypePlatformPlugin.h"
#include "autotype/AutoTypeAction.h"
#include "autotype/AutoTypePlatformPlugin.h"

class AutoTypePlatformMac : public QObject, public AutoTypePlatformInterface
{
Expand All @@ -45,7 +45,7 @@ class AutoTypePlatformMac : public QObject, public AutoTypePlatformInterface
bool raiseOwnWindow() override;

void sendChar(const QChar& ch, bool isKeyDown);
void sendKey(Qt::Key key, bool isKeyDown, Qt::KeyboardModifiers modifiers = 0);
void sendKey(Qt::Key key, bool isKeyDown, Qt::KeyboardModifiers modifiers = Qt::NoModifier);

private:
static int windowLayer(CFDictionaryRef window);
Expand All @@ -65,4 +65,4 @@ class AutoTypeExecutorMac : public AutoTypeExecutor
AutoTypePlatformMac* const m_platform;
};

#endif // KEEPASSX_AUTOTYPEMAC_H
#endif // KEEPASSX_AUTOTYPEMAC_H
2 changes: 1 addition & 1 deletion src/autotype/mac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(autotype_mac_SOURCES AutoTypeMac.cpp)

add_library(keepassxc-autotype-cocoa MODULE ${autotype_mac_SOURCES})
set_target_properties(keepassxc-autotype-cocoa PROPERTIES LINK_FLAGS "-framework Foundation -framework AppKit -framework Carbon")
target_link_libraries(keepassxc-autotype-cocoa ${PROGNAME} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-cocoa ${PROGNAME} Qt6::Core Qt6::Widgets)

install(TARGETS keepassxc-autotype-cocoa
LIBRARY DESTINATION ${PLUGIN_INSTALL_DIR} COMPONENT Runtime)
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} Qt5::Core Qt5::Widgets)
target_link_libraries(keepassxc-autotype-test keepassx_core ${autotype_LIB} Qt6::Core Qt6::Widgets)
4 changes: 2 additions & 2 deletions src/browser/BrowserService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ bool BrowserService::isPasskeyCredentialExcluded(const QJsonArray& excludeCreden
{
QStringList allIds;
for (const auto& cred : excludeCredentials) {
allIds << cred["id"].toString();
allIds << cred.toObject().value("id").toString();
}

const auto passkeyEntries = getPasskeyEntries(origin, keyList);
Expand Down Expand Up @@ -1604,7 +1604,7 @@ void BrowserService::processClientMessage(QLocalSocket* socket, const QJsonObjec
m_browserClients.insert(clientID, QSharedPointer<BrowserAction>::create());
}

auto& action = m_browserClients.value(clientID);
const auto& action = m_browserClients.value(clientID);
auto response = action->processClientMessage(socket, message);
m_browserHost->sendClientMessage(socket, response);
}
2 changes: 1 addition & 1 deletion src/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ if(WITH_XC_BROWSER)
endif()

add_library(keepassxcbrowser STATIC ${keepassxcbrowser_SOURCES})
target_link_libraries(keepassxcbrowser Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network ${BOTAN_LIBRARIES})
target_link_libraries(keepassxcbrowser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network ${BOTAN_LIBRARIES})
endif()
4 changes: 2 additions & 2 deletions src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2019 KeePassXC Team
# Copyright (C) 2023 KeePassXC Team
#
# 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 @@ -45,7 +45,7 @@ set(cli_SOURCES
Show.cpp)

add_library(cli STATIC ${cli_SOURCES})
target_link_libraries(cli Qt5::Core)
target_link_libraries(cli Qt6::Core)

find_package(Readline)

Expand Down
3 changes: 2 additions & 1 deletion src/cli/TextStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void TextStream::detectCodec()
codecName = env.value("ENCODING_OVERRIDE", codecName);
auto* codec = QTextCodec::codecForName(codecName.toLatin1());
if (codec) {
setCodec(codec);
// TODO: Solve
// setCodec(codec);
}
}
Loading

0 comments on commit 3843e83

Please sign in to comment.