Skip to content

Commit 8cd8a57

Browse files
committed
Add support for tab encryption
This enables encrypting all tab data on disk that are not handled by plugins (i.e. Synchronization and Encryption which itself uses gpg) using single password. The feature is disabled by default, needs to be enabled in build and in Preferences. Requires [QCA library](https://invent.kde.org/libraries/qca) and keyring support needs [QtKeychain](https://github.com/frankosterfeld/qtkeychain). To check if encryption is supported by the app (from Action dialog or command line): ```bash copyq 'popup("Encryption", info("has-encryption") === "1" ? "Supported" : "NOT supported")' copyq 'popup("Keychain Access", info("has-keychain") === "1" ? "Supported" : "NOT supported")' ``` Assisted-by: Claude Code Fixes #2617
1 parent f590752 commit 8cd8a57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3658
-575
lines changed

.claude/settings.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(cmake -B build *)",
5+
"Bash(build/copyq-tests *)",
6+
"Bash(build/copyq *)"
7+
]
8+
},
9+
"env": {
10+
"COPYQ_SESSION_NAME": "test",
11+
"COPYQ_SETTINGS_PATH": "build/copyq-test-conf",
12+
"COPYQ_ITEM_DATA_PATH": "build/copyq-test-data",
13+
"COPYQ_PLUGINS": "",
14+
"COPYQ_DEFAULT_ICON": "1",
15+
"COPYQ_SESSION_COLOR": "#f90",
16+
"COPYQ_THEME_PREFIX": "$PWD/shared/themes",
17+
"COPYQ_PASSWORD": "TEST123",
18+
"COPYQ_LOG_LEVEL": "DEBUG",
19+
"QT_LOGGING_RULES": "*.debug=true;qt.*.debug=false",
20+
"QT_QPA_PLATFORM": "minimal"
21+
}
22+
}

.github/workflows/build-linux.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ env:
4747
qt6-wayland
4848
qt6-wayland-dev
4949
qt6-wayland-dev-tools
50+
51+
libqca-qt6-dev
52+
libqca-qt6-2
53+
libqca-qt6-plugins
54+
55+
qtkeychain-qt6-dev
5056
qt5_packages: >-
5157
qtbase5-dev
5258
qtbase5-dev-tools
@@ -65,6 +71,12 @@ env:
6571
qtwayland5-dev-tools
6672
6773
libkf5notifications-dev
74+
75+
libqca-qt5-2-dev
76+
libqca-qt5-2
77+
libqca-qt5-2-plugins
78+
79+
qtkeychain-qt5-dev
6880
# FIXME: Sending signal to client process does not cause the process
6981
# to exit with non-zero code with GitHub Actions. Why?
7082
COPYQ_TESTS_SKIP_SIGNAL: '1'

.github/workflows/build-macos.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,11 @@ jobs:
7777
- name: Test
7878
working-directory: '${{runner.workspace}}/build/copyq/${{ matrix.cmake_preset }}'
7979
run: '${{github.workspace}}/utils/github/test-macos.sh'
80+
81+
- name: Upload crash reports
82+
if: failure()
83+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4
84+
with:
85+
name: 'crash-reports${{ matrix.bundle_suffix }}'
86+
path: '~/Library/Logs/DiagnosticReports/*'
87+
if-no-files-found: ignore

CLAUDE.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
## Commands
2+
3+
Always use the following environment variables for all `build/copyq` and
4+
`build/copyq-tests` commands:
5+
6+
export COPYQ_SESSION_NAME="test"
7+
export COPYQ_SETTINGS_PATH="build/copyq-test-conf"
8+
export COPYQ_ITEM_DATA_PATH="build/copyq-test-data"
9+
export COPYQ_PLUGINS=""
10+
export COPYQ_DEFAULT_ICON="1"
11+
export COPYQ_SESSION_COLOR="#f90"
12+
export COPYQ_THEME_PREFIX="$PWD/shared/themes"
13+
export COPYQ_PASSWORD="TEST123"
14+
export COPYQ_LOG_LEVEL="DEBUG"
15+
export QT_LOGGING_RULES="*.debug=true;qt.*.debug=false"
16+
export QT_QPA_PLATFORM="minimal"
17+
18+
Run CMake to configure build:
19+
20+
cmake -B build -G Ninja \
21+
-DCMAKE_BUILD_TYPE=Debug \
22+
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
23+
-DCMAKE_INSTALL_PREFIX=$PWD/build/install \
24+
-DCMAKE_CXX_FLAGS="-ggdb -fdiagnostics-color" \
25+
-DWITH_TESTS=ON \
26+
-DPEDANTIC=ON .
27+
28+
Build: `cmake -B build --build`
29+
30+
Install: `cmake -B build --target install`
31+
32+
Run tests after build: `build/copyq-tests $TEST_FUNCTIONS`
33+
34+
Run tests for specific plugin: `build/copyq-tests PLUGINS:sync $TEST_FUNCTIONS`
35+
36+
List tests function names: `build/copyq-tests -functions`
37+
38+
List tests function names for a plugin: `build/copyq-tests PLUGINS:image -functions`
39+
40+
Start the server process: `build/copyq`
41+
42+
In case any process exits with exit code 11 (SIGSEGV) use `coredumpctl` utility
43+
to find the root cause.
44+
45+
Stop the server process: `build/copyq exit`
46+
47+
List server and client logs (server process does not need to run): `build/copyq logs`
48+
49+
Run a script - requires server to be running:
50+
51+
build/copyq source script.js
52+
53+
# the above command is equivalent to
54+
build/copyq 'source("script.js")'
55+
56+
Scripting API documentation is in @docs/scripting-api.rst.
57+
58+
Useful scripts (omit the `tab(...)` call to use the default tab):
59+
60+
- `tab('TAB1'); add('ITEM')` - prepend ITEM text item to the TAB1 tab
61+
- `tab('TAB1'); size()` - item count in the TAB1 tab
62+
- `tab('TAB1'); read(0,1,2)` - read items at indexes 0, 1 and 2 in the TAB1 tab
63+
- `config()` - list configuration options with current value and description
64+
- `config('check_clipboard', 'false')` - set an option
65+
66+
## Project structure
67+
68+
- @plugins - code for various plugins build as dynamic modules loaded optionally by the app
69+
- @src - main app code
70+
- @src/app - wrappers for QCoreApplication object
71+
- @src/common - common functionality, client/server local socket handling, logging
72+
- @src/gui - GUI widgets and some helper modules
73+
- @src/item - tab and item data handling, serialization code
74+
- @src/platform - platform-specific code
75+
- @src/scriptable - scripting capabilities
76+
- @src/tests - tests for the main app
77+
- @src/ui - Qt widget definition files (XML)
78+
- @qxt - code to handle global system-wide shortcuts

CMakeLists.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ OPTION(PEDANTIC "Enable all compiler warnings" OFF)
2323

2424
# Options (cmake -LH)
2525
OPTION(WITH_PLUGINS "Compile plugins" ON)
26+
OPTION(WITH_QCA_ENCRYPTION "Enable QCA-based tab encryption" ON)
27+
OPTION(WITH_KEYCHAIN "Enable system keyring integration using QtKeychain" ON)
2628

2729
add_definitions( -DQT_USE_STRINGBUILDER )
2830

@@ -60,6 +62,27 @@ endif()
6062

6163
list(APPEND copyq_LIBRARIES ${copyq_qt}::Widgets)
6264

65+
# QCA encryption support
66+
if (WITH_QCA_ENCRYPTION)
67+
find_package(Qca-qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED)
68+
list(APPEND copyq_LIBRARIES qca-qt${QT_DEFAULT_MAJOR_VERSION})
69+
add_definitions(-DWITH_QCA_ENCRYPTION)
70+
message(STATUS "QCA encryption support enabled")
71+
else()
72+
message(STATUS "QCA encryption support DISABLED")
73+
set(WITH_KEYCHAIN OFF)
74+
endif()
75+
76+
# QtKeychain support for system keyring integration
77+
if (WITH_KEYCHAIN)
78+
find_package(Qt${QT_DEFAULT_MAJOR_VERSION}Keychain REQUIRED)
79+
list(APPEND copyq_LIBRARIES qt${QT_DEFAULT_MAJOR_VERSION}keychain)
80+
add_definitions(-DWITH_KEYCHAIN)
81+
message(STATUS "Keychain support enabled")
82+
else()
83+
message(STATUS "Keychain support disabled")
84+
endif()
85+
6386
set(copyq_APP_ID com.github.hluk.copyq)
6487
set(copyq_ICON_PREFIX src/images/icon)
6588
set(copyq_ICON_NORMAL src/images/icon.svg)
@@ -73,7 +96,7 @@ set(copyq_MANPAGE debian/copyq.1)
7396
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
7497
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
7598
set(CMAKE_CXX_FLAGS_DEBUG
76-
"${CMAKE_CXX_FLAGS_DEBUG} -Wextra -Wall -pedantic -Wfloat-equal -Woverloaded-virtual -Wundef -Wno-inconsistent-missing-destructor-override")
99+
"${CMAKE_CXX_FLAGS_DEBUG} -Wextra -Wall -pedantic -Wfloat-equal -Woverloaded-virtual -Wundef -Wno-inconsistent-missing-destructor-override -Wno-variadic-macro-arguments-omitted")
77100
endif()
78101

79102
if (PEDANTIC)

CMakePresets.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"installDir": "${sourceParentDir}/install/copyq/${presetName}",
99
"cacheVariables": {
1010
"WITH_TESTS": "TRUE",
11+
"WITH_QCA_ENCRYPTION": "TRUE",
1112
"PEDANTIC": "TRUE",
1213
"CMAKE_BUILD_TYPE": "Debug",
1314
"CMAKE_C_COMPILER_LAUNCHER": "ccache",

appveyor.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ environment:
1818
KF_BRANCH: stable
1919
KF_PATCH: 0
2020
SNORETOAST_VERSION: 0.9.0
21+
QCA_VERSION: 2.3.10
22+
QTKEYCHAIN_VERSION: 0.15.0
2123

2224
matrix:
2325
- QTDIR: /c/Qt/6.8/msvc2022_64
@@ -28,11 +30,13 @@ environment:
2830
BUILD_SUB_DIR: Release
2931
# https://wiki.qt.io/Qt_6.8_Tools_and_Versions
3032
# https://www.appveyor.com/docs/windows-images-software/#tools
31-
OPENSSL_PATH: /c/OpenSSL-v30-Win64/bin
32-
LIBSSL: libssl-3-x64.dll
33-
LIBCRYPTO: libcrypto-3-x64.dll
33+
LIBSSL: /c/OpenSSL-v30-Win64/bin/libssl-3-x64.dll
34+
LIBCRYPTO: /c/OpenSSL-v30-Win64/bin/libcrypto-3-x64.dll
35+
LIBSSL_FOR_QCA: /c/OpenSSL-Win64/bin/libssl-1_1-x64.dll
36+
LIBCRYPTO_FOR_QCA: /c/OpenSSL-Win64/bin/libcrypto-1_1-x64.dll
3437
GPGPATH: /c/Program Files/Git/usr/bin
3538
WITH_NATIVE_NOTIFICATIONS: "ON"
39+
WITH_QCA_ENCRYPTION: "ON"
3640
WITH_QT6: "ON"
3741
WINDEPLOYQT_ARGS: >-
3842
--no-system-d3d-compiler

plugins/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@ copyq_add_plugin_obj(copyq-plugin-common
5959
)
6060
copyq_add_plugin_obj(copyq-plugin-wrapper ../src/item/itemwidgetwrapper.cpp)
6161
copyq_add_plugin_obj(copyq-plugin-textdata ../src/common/textdata.cpp)
62+
copyq_add_plugin_obj(copyq-plugin-geometry ../src/gui/geometry.cpp)
6263
copyq_add_plugin_obj(copyq-plugin-screen ../src/gui/screen.cpp)
63-
copyq_add_plugin_obj(copyq-plugin-serialize ../src/item/serialize.cpp)
64+
copyq_add_plugin_obj(copyq-plugin-serialize
65+
../src/item/serialize.cpp
66+
../src/common/encryption.cpp
67+
)
6468
copyq_add_plugin_obj(copyq-plugin-config ../src/common/config.cpp)
6569
copyq_add_plugin_obj(copyq-plugin-iconfont ../src/gui/iconfont.cpp)
6670
copyq_add_plugin_obj(copyq-plugin-iconwidget ../src/gui/iconwidget.cpp)

plugins/itemimage/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
set(copyq_plugin_itemimage_SOURCES
2+
$<TARGET_OBJECTS:copyq-plugin-config>
23
$<TARGET_OBJECTS:copyq-plugin-serialize>
34
../../src/common/action.cpp
45
../../src/common/process.cpp

plugins/itemsync/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(copyq_plugin_itemsync_SOURCES
22
$<TARGET_OBJECTS:copyq-plugin-config>
3+
$<TARGET_OBJECTS:copyq-plugin-geometry>
34
$<TARGET_OBJECTS:copyq-plugin-iconfont>
45
$<TARGET_OBJECTS:copyq-plugin-iconwidget>
56
$<TARGET_OBJECTS:copyq-plugin-screen>

0 commit comments

Comments
 (0)