mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-04-23 14:07:32 -04:00
Compare commits
150 commits
release-5.
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
0b3bce8993 | ||
|
0160aa28b6 | ||
|
0187f19f60 | ||
|
e87dfe35f3 | ||
|
e51be45ce6 | ||
|
b4a16f6464 | ||
|
250fef4ee7 | ||
|
8fc5d0914d | ||
|
fc5daf6e1d | ||
|
c878a09d27 | ||
|
2aee875642 | ||
|
2785636d3f | ||
|
15069b2643 | ||
|
f0361f1bed | ||
|
110e6d32b4 | ||
|
3d73026ff2 | ||
|
abafbc0685 | ||
|
5465605377 | ||
|
9331580e86 | ||
|
795889c417 | ||
|
ff03eeab5b | ||
|
f0b9a17566 | ||
|
72e8b3272b | ||
|
6c36830e5e | ||
|
cdddaae939 | ||
|
f540381caf | ||
|
055d82bda4 | ||
|
0796f96ee4 | ||
|
841cffafa7 | ||
|
ade39432be | ||
|
830d2c207b | ||
|
97865545c3 | ||
|
3abdc3134b | ||
|
5a716a40fb | ||
|
943e403241 | ||
|
103ea813dc | ||
|
52b1f3588a | ||
|
4bd50672e8 | ||
|
8c8a0ac54c | ||
|
7b4a3fccc6 | ||
|
d21653e8cf | ||
|
627d89813c | ||
|
b28c229f85 | ||
|
8d0870c953 | ||
|
5a4b3b25d3 | ||
|
d174bc75e4 | ||
|
882da47609 | ||
|
b74b334e34 | ||
|
53f919aea8 | ||
|
62a7fd86d6 | ||
|
96295adc08 | ||
|
8f53fb8178 | ||
|
37eb80919c | ||
|
1b044d9476 | ||
|
83599f1f7b | ||
|
6e1b5ec18b | ||
|
249c80aaaf | ||
|
0ac47496d4 | ||
|
4ec80de268 | ||
|
f432c1e615 | ||
|
41d9ee91a1 | ||
|
ba3d89b674 | ||
|
1ca33d45ba | ||
|
a9b54d94a0 | ||
|
693390ff27 | ||
|
5ddc5a8b87 | ||
|
ad9100ac07 | ||
|
1043bea896 | ||
|
955688c125 | ||
|
8da43a4054 | ||
|
ddf6dd5fa2 | ||
|
8c02bbb4bc | ||
|
7e95375cec | ||
|
29201fa016 | ||
|
1a3d0f6fab | ||
|
f58d6ae984 | ||
|
7f0134108a | ||
|
d79dc86d00 | ||
|
38070c6eee | ||
|
c9eb1fbac8 | ||
|
7238bad5a6 | ||
|
bd564a99a3 | ||
|
b052ad0923 | ||
|
c65a68251e | ||
|
93925042dd | ||
|
e55b59d9ca | ||
|
f8469d02f7 | ||
|
dc10b88cec | ||
|
4406a3f173 | ||
|
9c2e698514 | ||
|
463700b76d | ||
|
86387fbe49 | ||
|
a018cfa56c | ||
|
b76054beba | ||
|
f8536162f2 | ||
|
af65ddd012 | ||
|
fe9dc131bc | ||
|
bb4a668ddd | ||
|
3978137534 | ||
|
3ef4d0d798 | ||
|
e2341f5217 | ||
|
abd3cd54bc | ||
|
dc8ac38494 | ||
|
e3eacf2bf7 | ||
|
5098519d46 | ||
|
82c36aea89 | ||
|
05787d94ec | ||
|
f8c48349a1 | ||
|
1ee84033ec | ||
|
f2eecf8a4e | ||
|
76e1040232 | ||
|
4686d6709e | ||
|
2cc7ec90a8 | ||
|
99adb16090 | ||
|
c622d50814 | ||
|
11991e62f5 | ||
|
82d90e599c | ||
|
45b7947cd0 | ||
|
2e21cf76de | ||
|
76151110e5 | ||
|
5875d8bff3 | ||
|
68ecb13d14 | ||
|
f9f4b60b83 | ||
|
4fc36b9e99 | ||
|
4f3d77963f | ||
|
d911928c59 | ||
|
22e156e0af | ||
|
6fe02895a8 | ||
|
395dbaa5c6 | ||
|
efe06f133d | ||
|
9c0475ebfa | ||
|
e740a42366 | ||
|
cc31a90931 | ||
|
90e457a671 | ||
|
7487cd7e6d | ||
|
bbc3c2832f | ||
|
879c6bf9ff | ||
|
f2097dc4b5 | ||
|
166feb5bdf | ||
|
a841fe9320 | ||
|
9709672b34 | ||
|
e2db0bc866 | ||
|
fee45e4ba6 | ||
|
257d928ab3 | ||
|
34c8849f22 | ||
|
1c82eb3dff | ||
|
7886ca65f9 | ||
|
85c4ddf616 | ||
|
0a36171999 | ||
|
c887a6f7d8 |
361 changed files with 220173 additions and 146826 deletions
2
.github/FUNDING.yml
vendored
2
.github/FUNDING.yml
vendored
|
@ -1 +1 @@
|
|||
custom: "https://www.qbittorrent.org/donate.php"
|
||||
custom: "https://www.qbittorrent.org/donate"
|
||||
|
|
31
.github/workflows/ci_file_health.yaml
vendored
31
.github/workflows/ci_file_health.yaml
vendored
|
@ -12,11 +12,15 @@ jobs:
|
|||
ci:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install tools
|
||||
- name: Setup python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "*"
|
||||
|
@ -32,7 +36,7 @@ jobs:
|
|||
curl \
|
||||
-L \
|
||||
-o "${{ runner.temp }}/pandoc.tar.gz" \
|
||||
"https://github.com/jgm/pandoc/releases/download/3.4/pandoc-3.4-linux-amd64.tar.gz"
|
||||
"https://github.com/jgm/pandoc/releases/download/3.6/pandoc-3.6-linux-amd64.tar.gz"
|
||||
tar -xf "${{ runner.temp }}/pandoc.tar.gz" -C "${{ github.workspace }}/.."
|
||||
mv "${{ github.workspace }}/.."/pandoc-* "${{ env.pandoc_path }}"
|
||||
# run pandoc
|
||||
|
@ -42,3 +46,26 @@ jobs:
|
|||
done
|
||||
# check diff, ignore "Automatically generated by ..." part
|
||||
git diff -I '\.\\".*' --exit-code
|
||||
|
||||
- name: Check GitHub Actions workflow
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
pip install zizmor
|
||||
IGNORE_RULEID='(.ruleId != "template-injection")
|
||||
and (.ruleId != "unpinned-uses")'
|
||||
IGNORE_ID='(.id != "template-injection")
|
||||
and (.id != "unpinned-uses")'
|
||||
zizmor \
|
||||
--format sarif \
|
||||
--pedantic \
|
||||
./ \
|
||||
| jq "(.runs[].results |= map(select($IGNORE_RULEID)))
|
||||
| (.runs[].tool.driver.rules |= map(select($IGNORE_ID)))" \
|
||||
> "${{ runner.temp }}/zizmor_results.sarif"
|
||||
|
||||
- name: Upload zizmor results
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
with:
|
||||
category: zizmor
|
||||
sarif_file: "${{ runner.temp }}/zizmor_results.sarif"
|
||||
|
|
24
.github/workflows/ci_macos.yaml
vendored
24
.github/workflows/ci_macos.yaml
vendored
|
@ -2,8 +2,7 @@ name: CI - macOS
|
|||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
|
@ -13,13 +12,15 @@ jobs:
|
|||
ci:
|
||||
name: Build
|
||||
runs-on: macos-latest
|
||||
permissions:
|
||||
actions: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
libt_version: ["2.0.10", "1.2.19"]
|
||||
libt_version: ["2.0.11", "1.2.20"]
|
||||
qbt_gui: ["GUI=ON", "GUI=OFF"]
|
||||
qt_version: ["6.7.0"]
|
||||
qt_version: ["6.9.0"]
|
||||
|
||||
env:
|
||||
boost_path: "${{ github.workspace }}/../boost"
|
||||
|
@ -28,6 +29,8 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install dependencies
|
||||
uses: Wandalen/wretry.action@v3
|
||||
|
@ -49,7 +52,7 @@ jobs:
|
|||
store_cache: ${{ github.ref == 'refs/heads/master' }}
|
||||
update_packager_index: false
|
||||
ccache_options: |
|
||||
max_size=2G
|
||||
max_size=1G
|
||||
|
||||
- name: Install boost
|
||||
env:
|
||||
|
@ -57,7 +60,7 @@ jobs:
|
|||
BOOST_MINOR_VERSION: "86"
|
||||
BOOST_PATCH_VERSION: "0"
|
||||
run: |
|
||||
boost_url="https://boostorg.jfrog.io/artifactory/main/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
boost_url="https://archives.boost.io/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
boost_url2="https://sourceforge.net/projects/boost/files/boost/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
set +e
|
||||
curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
|
||||
|
@ -67,6 +70,9 @@ jobs:
|
|||
tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
|
||||
fi
|
||||
mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
|
||||
cd "${{ env.boost_path }}"
|
||||
./bootstrap.sh
|
||||
./b2 stage --stagedir=./ --with-headers
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v4
|
||||
|
@ -90,9 +96,9 @@ jobs:
|
|||
-G "Ninja" \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_CXX_STANDARD=17 \
|
||||
-DCMAKE_CXX_STANDARD=20 \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" \
|
||||
-Ddeprecated-functions=OFF
|
||||
cmake --build build
|
||||
sudo cmake --install build
|
||||
|
@ -106,7 +112,7 @@ jobs:
|
|||
-G "Ninja" \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" \
|
||||
-DTESTING=ON \
|
||||
-DVERBOSE_CONFIGURE=ON \
|
||||
-D${{ matrix.qbt_gui }}
|
||||
|
|
6
.github/workflows/ci_python.yaml
vendored
6
.github/workflows/ci_python.yaml
vendored
|
@ -16,6 +16,8 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup python (auxiliary scripts)
|
||||
uses: actions/setup-python@v5
|
||||
|
@ -34,7 +36,7 @@ jobs:
|
|||
- name: Lint code (auxiliary scripts)
|
||||
run: |
|
||||
pyflakes $PY_FILES
|
||||
bandit --skip B314,B405 $PY_FILES
|
||||
bandit --skip B101,B314,B405 $PY_FILES
|
||||
|
||||
- name: Format code (auxiliary scripts)
|
||||
run: |
|
||||
|
@ -61,7 +63,7 @@ jobs:
|
|||
echo $PY_FILES
|
||||
echo "PY_FILES=$PY_FILES" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Check typings (search engine)
|
||||
- name: Check typings (search engine)
|
||||
run: |
|
||||
MYPYPATH="src/searchengine/nova3" \
|
||||
mypy \
|
||||
|
|
40
.github/workflows/ci_ubuntu.yaml
vendored
40
.github/workflows/ci_ubuntu.yaml
vendored
|
@ -2,9 +2,7 @@ name: CI - Ubuntu
|
|||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
security-events: write
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
|
@ -14,22 +12,27 @@ jobs:
|
|||
ci:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: write
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
libt_version: ["2.0.10", "1.2.19"]
|
||||
libt_version: ["2.0.11", "1.2.20"]
|
||||
qbt_gui: ["GUI=ON", "GUI=OFF"]
|
||||
qt_version: ["6.5.2"]
|
||||
|
||||
env:
|
||||
boost_path: "${{ github.workspace }}/../boost"
|
||||
harden_flags: "-D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS"
|
||||
harden_flags: "-D_FORTIFY_SOURCE=3 -D_GLIBCXX_ASSERTIONS"
|
||||
libtorrent_path: "${{ github.workspace }}/../libtorrent"
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
@ -44,15 +47,15 @@ jobs:
|
|||
store_cache: ${{ github.ref == 'refs/heads/master' }}
|
||||
update_packager_index: false
|
||||
ccache_options: |
|
||||
max_size=2G
|
||||
max_size=1G
|
||||
|
||||
- name: Install boost
|
||||
env:
|
||||
BOOST_MAJOR_VERSION: "1"
|
||||
BOOST_MINOR_VERSION: "76"
|
||||
BOOST_MINOR_VERSION: "77"
|
||||
BOOST_PATCH_VERSION: "0"
|
||||
run: |
|
||||
boost_url="https://boostorg.jfrog.io/artifactory/main/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
boost_url="https://archives.boost.io/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
boost_url2="https://sourceforge.net/projects/boost/files/boost/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
set +e
|
||||
curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
|
||||
|
@ -62,6 +65,9 @@ jobs:
|
|||
tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
|
||||
fi
|
||||
mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
|
||||
cd "${{ env.boost_path }}"
|
||||
./bootstrap.sh
|
||||
./b2 stage --stagedir=./ --with-headers
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v4
|
||||
|
@ -85,8 +91,9 @@ jobs:
|
|||
-G "Ninja" \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_CXX_STANDARD=20 \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" \
|
||||
-Ddeprecated-functions=OFF
|
||||
cmake --build build
|
||||
sudo cmake --install build
|
||||
|
@ -108,7 +115,7 @@ jobs:
|
|||
-G "Ninja" \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" \
|
||||
-DCMAKE_INSTALL_PREFIX="/usr" \
|
||||
-DTESTING=ON \
|
||||
-DVERBOSE_CONFIGURE=ON \
|
||||
|
@ -134,16 +141,15 @@ jobs:
|
|||
|
||||
- name: Install AppImage
|
||||
run: |
|
||||
sudo apt install libfuse2
|
||||
curl \
|
||||
-L \
|
||||
-Z \
|
||||
-O https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-static-x86_64.AppImage \
|
||||
-O https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-static-x86_64.AppImage \
|
||||
-O https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \
|
||||
-O https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage \
|
||||
-O https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage
|
||||
chmod +x \
|
||||
linuxdeploy-static-x86_64.AppImage \
|
||||
linuxdeploy-plugin-qt-static-x86_64.AppImage \
|
||||
linuxdeploy-x86_64.AppImage \
|
||||
linuxdeploy-plugin-qt-x86_64.AppImage \
|
||||
linuxdeploy-plugin-appimage-x86_64.AppImage
|
||||
|
||||
- name: Prepare files for AppImage
|
||||
|
@ -156,12 +162,12 @@ jobs:
|
|||
|
||||
- name: Package AppImage
|
||||
run: |
|
||||
./linuxdeploy-static-x86_64.AppImage --appdir qbittorrent --plugin qt
|
||||
./linuxdeploy-x86_64.AppImage --appdir qbittorrent --plugin qt
|
||||
rm qbittorrent/apprun-hooks/*
|
||||
cp .github/workflows/helper/appimage/export_vars.sh qbittorrent/apprun-hooks/export_vars.sh
|
||||
NO_APPSTREAM=1 \
|
||||
OUTPUT=upload/qbittorrent-CI_Ubuntu_x86_64.AppImage \
|
||||
./linuxdeploy-static-x86_64.AppImage --appdir qbittorrent --output appimage
|
||||
./linuxdeploy-x86_64.AppImage --appdir qbittorrent --output appimage
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
|
|
17
.github/workflows/ci_webui.yaml
vendored
17
.github/workflows/ci_webui.yaml
vendored
|
@ -2,8 +2,7 @@ name: CI - WebUI
|
|||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
security-events: write
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
|
@ -13,6 +12,8 @@ jobs:
|
|||
ci:
|
||||
name: Check
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
security-events: write
|
||||
|
||||
defaults:
|
||||
run:
|
||||
|
@ -21,6 +22,8 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup nodejs
|
||||
uses: actions/setup-node@v4
|
||||
|
@ -28,7 +31,15 @@ jobs:
|
|||
node-version: 'lts/*'
|
||||
|
||||
- name: Install tools
|
||||
run: npm install
|
||||
run: |
|
||||
npm install
|
||||
npm ls
|
||||
echo "::group::npm ls --all"
|
||||
npm ls --all
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Lint code
|
||||
run: npm run lint
|
||||
|
|
26
.github/workflows/ci_windows.yaml
vendored
26
.github/workflows/ci_windows.yaml
vendored
|
@ -2,8 +2,7 @@ name: CI - Windows
|
|||
|
||||
on: [pull_request, push]
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
|
@ -13,11 +12,13 @@ jobs:
|
|||
ci:
|
||||
name: Build
|
||||
runs-on: windows-latest
|
||||
permissions:
|
||||
actions: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
libt_version: ["2.0.10", "1.2.19"]
|
||||
libt_version: ["2.0.11", "1.2.20"]
|
||||
|
||||
env:
|
||||
boost_path: "${{ github.workspace }}/../boost"
|
||||
|
@ -27,6 +28,8 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup devcmd
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
|
@ -64,6 +67,7 @@ jobs:
|
|||
"set(VCPKG_BUILD_TYPE release)")
|
||||
# clear buildtrees after each package installation to reduce disk space requirements
|
||||
$packages = `
|
||||
"boost-build:x64-windows-static-md-release",
|
||||
"openssl:x64-windows-static-md-release",
|
||||
"zlib:x64-windows-static-md-release"
|
||||
${{ env.vcpkg_path }}/vcpkg.exe upgrade `
|
||||
|
@ -81,7 +85,7 @@ jobs:
|
|||
BOOST_MINOR_VERSION: "86"
|
||||
BOOST_PATCH_VERSION: "0"
|
||||
run: |
|
||||
$boost_url="https://boostorg.jfrog.io/artifactory/main/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
$boost_url="https://archives.boost.io/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
$boost_url2="https://sourceforge.net/projects/boost/files/boost/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
|
||||
tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."
|
||||
|
@ -91,11 +95,18 @@ jobs:
|
|||
tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."
|
||||
}
|
||||
move "${{ github.workspace }}/../boost_*" "${{ env.boost_path }}"
|
||||
cd "${{ env.boost_path }}"
|
||||
#.\bootstrap.bat
|
||||
${{ env.vcpkg_path }}/installed/x64-windows-static-md-release/tools/boost-build/b2.exe `
|
||||
stage `
|
||||
toolset=msvc `
|
||||
--stagedir=.\ `
|
||||
--with-headers
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v4
|
||||
with:
|
||||
version: "6.8.0"
|
||||
version: "6.9.0"
|
||||
arch: win64_msvc2022_64
|
||||
archives: qtbase qtsvg qttools
|
||||
cache: true
|
||||
|
@ -115,10 +126,11 @@ jobs:
|
|||
-B build `
|
||||
-G "Ninja" `
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
||||
-DCMAKE_CXX_STANDARD=20 `
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
|
||||
-DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}/install" `
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" `
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" `
|
||||
-DBUILD_SHARED_LIBS=OFF `
|
||||
-Ddeprecated-functions=OFF `
|
||||
-Dstatic_runtime=OFF `
|
||||
|
@ -135,7 +147,7 @@ jobs:
|
|||
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
|
||||
-DCMAKE_TOOLCHAIN_FILE="${{ env.vcpkg_path }}/scripts/buildsystems/vcpkg.cmake" `
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" `
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" `
|
||||
-DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/install/lib/cmake/LibtorrentRasterbar" `
|
||||
-DMSVC_RUNTIME_DYNAMIC=ON `
|
||||
-DTESTING=ON `
|
||||
|
|
14
.github/workflows/coverity-scan.yaml
vendored
14
.github/workflows/coverity-scan.yaml
vendored
|
@ -14,7 +14,7 @@ jobs:
|
|||
|
||||
strategy:
|
||||
matrix:
|
||||
libt_version: ["2.0.10"]
|
||||
libt_version: ["2.0.11"]
|
||||
qbt_gui: ["GUI=ON"]
|
||||
qt_version: ["6.5.2"]
|
||||
|
||||
|
@ -26,6 +26,8 @@ jobs:
|
|||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
@ -40,7 +42,7 @@ jobs:
|
|||
BOOST_MINOR_VERSION: "86"
|
||||
BOOST_PATCH_VERSION: "0"
|
||||
run: |
|
||||
boost_url="https://boostorg.jfrog.io/artifactory/main/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
boost_url="https://archives.boost.io/release/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/source/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
boost_url2="https://sourceforge.net/projects/boost/files/boost/${{ env.BOOST_MAJOR_VERSION }}.${{ env.BOOST_MINOR_VERSION }}.${{ env.BOOST_PATCH_VERSION }}/boost_${{ env.BOOST_MAJOR_VERSION }}_${{ env.BOOST_MINOR_VERSION }}_${{ env.BOOST_PATCH_VERSION }}.tar.gz"
|
||||
set +e
|
||||
curl -L -o "${{ runner.temp }}/boost.tar.gz" "$boost_url"
|
||||
|
@ -50,6 +52,9 @@ jobs:
|
|||
tar -xf "${{ runner.temp }}/boost.tar.gz" -C "${{ github.workspace }}/.."; _exitCode="$?"
|
||||
fi
|
||||
mv "${{ github.workspace }}/.."/boost_* "${{ env.boost_path }}"
|
||||
cd "${{ env.boost_path }}"
|
||||
./bootstrap.sh
|
||||
./b2 stage --stagedir=./ --with-headers
|
||||
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v4
|
||||
|
@ -71,7 +76,8 @@ jobs:
|
|||
-B build \
|
||||
-G "Ninja" \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" \
|
||||
-DCMAKE_CXX_STANDARD=20 \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" \
|
||||
-Ddeprecated-functions=OFF
|
||||
cmake --build build
|
||||
sudo cmake --install build
|
||||
|
@ -95,7 +101,7 @@ jobs:
|
|||
-B build \
|
||||
-G "Ninja" \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}" \
|
||||
-DBOOST_ROOT="${{ env.boost_path }}/lib/cmake" \
|
||||
-DVERBOSE_CONFIGURE=ON \
|
||||
-D${{ matrix.qbt_gui }}
|
||||
PATH="${{ env.coverity_path }}/bin:$PATH" \
|
||||
|
|
95
.github/workflows/helper/pre-commit/check_grid_items_order.py
vendored
Executable file
95
.github/workflows/helper/pre-commit/check_grid_items_order.py
vendored
Executable file
|
@ -0,0 +1,95 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# A pre-commit hook for checking items order in grid layouts
|
||||
# Copyright (C) 2024 Mike Tzou (Chocobo1)
|
||||
#
|
||||
# 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 the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give permission to
|
||||
# link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
# modified versions of it that use the same license as the "OpenSSL" library),
|
||||
# and distribute the linked executables. You must obey the GNU General Public
|
||||
# License in all respects for all of the code used other than "OpenSSL". If you
|
||||
# modify file(s), you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
# exception statement from your version.
|
||||
|
||||
from collections.abc import Callable, Sequence
|
||||
from typing import Optional
|
||||
import argparse
|
||||
import re
|
||||
import xml.etree.ElementTree as ElementTree
|
||||
import sys
|
||||
|
||||
|
||||
def traversePostOrder(root: ElementTree.Element, visitFunc: Callable[[ElementTree.Element], None]) -> None:
|
||||
stack = [(root, False)]
|
||||
|
||||
while len(stack) > 0:
|
||||
(element, visit) = stack.pop()
|
||||
if visit:
|
||||
visitFunc(element)
|
||||
else:
|
||||
stack.append((element, True))
|
||||
stack.extend((child, False) for child in reversed(element))
|
||||
|
||||
|
||||
def modifyElement(element: ElementTree.Element) -> None:
|
||||
def getSortKey(e: ElementTree.Element) -> tuple[int, int]:
|
||||
if e.tag == 'item':
|
||||
return (int(e.attrib['row']), int(e.attrib['column']))
|
||||
return (-1, -1) # don't care
|
||||
|
||||
if element.tag == 'layout' and element.attrib['class'] == 'QGridLayout' and len(element) > 0:
|
||||
element[:] = sorted(element, key=getSortKey)
|
||||
|
||||
# workaround_2a: ElementTree will unescape `"` and we need to escape it back
|
||||
if element.tag == 'string' and element.text is not None:
|
||||
element.text = element.text.replace('"', '"')
|
||||
|
||||
|
||||
def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('filenames', nargs='*', help='Filenames to check')
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
for filename in args.filenames:
|
||||
with open(filename, 'r+') as f:
|
||||
orig = f.read()
|
||||
root = ElementTree.fromstring(orig)
|
||||
traversePostOrder(root, modifyElement)
|
||||
ElementTree.indent(root, ' ')
|
||||
|
||||
# workaround_1: cannot use `xml_declaration=True` since it uses single quotes instead of Qt preferred double quotes
|
||||
ret = f'<?xml version="1.0" encoding="UTF-8"?>\n{ElementTree.tostring(root, 'unicode')}\n'
|
||||
|
||||
# workaround_2b: ElementTree will turn `"` into `&quot;`, so revert it back
|
||||
ret = ret.replace('&quot;', '"')
|
||||
|
||||
# workaround_3: Qt prefers no whitespaces in self-closing tags
|
||||
ret = re.sub('<(.+) +/>', r'<\1/>', ret)
|
||||
|
||||
if ret != orig:
|
||||
print(f'Tip: run this script to apply the fix: `python {__file__} {filename}`', file=sys.stderr)
|
||||
|
||||
f.seek(0)
|
||||
f.write(ret)
|
||||
f.truncate()
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
|
@ -26,9 +26,11 @@
|
|||
# but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
# exception statement from your version.
|
||||
|
||||
from typing import Optional, Sequence
|
||||
from collections.abc import Sequence
|
||||
from typing import Optional
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def main(argv: Optional[Sequence[str]] = None) -> int:
|
||||
|
@ -67,4 +69,4 @@ def main(argv: Optional[Sequence[str]] = None) -> int:
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(main())
|
||||
sys.exit(main())
|
||||
|
|
5
.github/workflows/stale_bot.yaml
vendored
5
.github/workflows/stale_bot.yaml
vendored
|
@ -4,12 +4,13 @@ on:
|
|||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Mark and close stale PRs
|
||||
uses: actions/stale@v9
|
||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -41,7 +41,3 @@ src/icons/skin/build-icons/icons/*.png
|
|||
|
||||
# CMake build directory
|
||||
build/
|
||||
|
||||
# Web UI tools
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: check-grid-order
|
||||
name: Check items order in grid layouts
|
||||
entry: .github/workflows/helper/pre-commit/check_grid_items_order.py
|
||||
language: script
|
||||
files: \.ui$
|
||||
|
||||
- id: check-translation-tag
|
||||
name: Check newline characters in <translation> tag
|
||||
entry: .github/workflows/helper/pre-commit/check_translation_tag.py
|
||||
|
@ -13,7 +19,7 @@ repos:
|
|||
- ts
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks.git
|
||||
rev: v4.6.0
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: check-json
|
||||
name: Check JSON files
|
||||
|
@ -63,11 +69,11 @@ repos:
|
|||
- ts
|
||||
|
||||
- repo: https://github.com/codespell-project/codespell.git
|
||||
rev: v2.3.0
|
||||
rev: v2.4.0
|
||||
hooks:
|
||||
- id: codespell
|
||||
name: Check spelling (codespell)
|
||||
args: ["--ignore-words-list", "additionals,categor,curren,fo,ist,ket,notin,searchin,sectionin,superseeding,te,ths"]
|
||||
args: ["--ignore-words-list", "additionals,categor,curren,fo,indexIn,ist,ket,notin,searchin,sectionin,superseeding,te,ths"]
|
||||
exclude: |
|
||||
(?x)^(
|
||||
.*\.desktop |
|
||||
|
@ -82,7 +88,7 @@ repos:
|
|||
- ts
|
||||
|
||||
- repo: https://github.com/crate-ci/typos.git
|
||||
rev: v1.25.0
|
||||
rev: v1.29.4
|
||||
hooks:
|
||||
- id: typos
|
||||
name: Check spelling (typos)
|
||||
|
|
5
WebAPI_Changelog.md
Normal file
5
WebAPI_Changelog.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# 2.11.6
|
||||
* https://github.com/qbittorrent/qBittorrent/pull/22460
|
||||
* `app/setPreferences` allows only one of `max_ratio_enabled`, `max_ratio` to be present
|
||||
* `app/setPreferences` allows only one of `max_seeding_time_enabled`, `max_seeding_time` to be present
|
||||
* `app/setPreferences` allows only one of `max_inactive_seeding_time_enabled`, `max_inactive_seeding_time` to be present
|
4
dist/mac/Info.plist
vendored
4
dist/mac/Info.plist
vendored
|
@ -55,7 +55,7 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>5.1.0</string>
|
||||
<string>5.2.0</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
|
@ -67,7 +67,7 @@
|
|||
<key>NSAppleScriptEnabled</key>
|
||||
<string>YES</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2006-2024 The qBittorrent project</string>
|
||||
<string>Copyright © 2006-2025 The qBittorrent project</string>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
|
146
dist/unix/org.qbittorrent.qBittorrent.desktop
vendored
146
dist/unix/org.qbittorrent.qBittorrent.desktop
vendored
|
@ -14,216 +14,220 @@ Keywords=bittorrent;torrent;magnet;download;p2p;
|
|||
SingleMainWindow=true
|
||||
|
||||
# Translations
|
||||
Comment[af]=Aflaai en deel lêers oor BitTorrent
|
||||
GenericName[af]=BitTorrent kliënt
|
||||
Comment[af]=Aflaai en deel lêers oor BitTorrent
|
||||
Name[af]=qBittorrent
|
||||
Comment[ar]=نزّل وشارك الملفات عبر كيوبتتورنت
|
||||
GenericName[ar]=عميل بتتورنت
|
||||
Comment[ar]=نزّل وشارك الملفات عبر كيوبتتورنت
|
||||
Name[ar]=qBittorrent
|
||||
Comment[be]=Спампоўванне і раздача файлаў праз пратакол BitTorrent
|
||||
GenericName[be]=Кліент BitTorrent
|
||||
Comment[be]=Спампоўванне і раздача файлаў праз пратакол BitTorrent
|
||||
Name[be]=qBittorrent
|
||||
Comment[bg]=Сваляне и споделяне на файлове чрез BitTorrent
|
||||
GenericName[bg]=BitTorrent клиент
|
||||
Comment[bg]=Сваляне и споделяне на файлове чрез BitTorrent
|
||||
Name[bg]=qBittorrent
|
||||
Comment[bn]=বিটটরেন্টে ফাইল ডাউনলোড এবং শেয়ার করুন
|
||||
GenericName[bn]=বিটটরেন্ট ক্লায়েন্ট
|
||||
Comment[bn]=বিটটরেন্টে ফাইল ডাউনলোড এবং শেয়ার করুন
|
||||
Name[bn]=qBittorrent
|
||||
Comment[zh]=通过 BitTorrent 下载和分享文件
|
||||
GenericName[zh]=BitTorrent 客户端
|
||||
Comment[zh]=通过 BitTorrent 下载和分享文件
|
||||
Name[zh]=qBittorrent
|
||||
Comment[bs]=Preuzmi i dijeli datoteke preko BitTorrent-a
|
||||
GenericName[bs]=BitTorrent klijent
|
||||
Comment[bs]=Preuzmi i dijeli datoteke preko BitTorrent-a
|
||||
Name[bs]=qBittorrent
|
||||
Comment[ca]=Baixeu i compartiu fitxers amb el BitTorrent
|
||||
GenericName[ca]=Client de BitTorrent
|
||||
Comment[ca]=Baixeu i compartiu fitxers amb el BitTorrent
|
||||
Name[ca]=qBittorrent
|
||||
Comment[cs]=Stahování a sdílení souborů přes síť BitTorrent
|
||||
GenericName[cs]=BitTorrent klient
|
||||
Comment[cs]=Stahování a sdílení souborů přes síť BitTorrent
|
||||
Name[cs]=qBittorrent
|
||||
Comment[da]=Download og del filer over BitTorrent
|
||||
GenericName[da]=BitTorrent-klient
|
||||
Comment[da]=Download og del filer over BitTorrent
|
||||
Name[da]=qBittorrent
|
||||
Comment[de]=Über BitTorrent Dateien herunterladen und teilen
|
||||
GenericName[de]=BitTorrent Client
|
||||
Comment[de]=Über BitTorrent Dateien herunterladen und teilen
|
||||
Name[de]=qBittorrent
|
||||
Comment[el]=Κάντε λήψη και μοιραστείτε αρχεία μέσω BitTorrent
|
||||
GenericName[el]=BitTorrent client
|
||||
Comment[el]=Κάντε λήψη και μοιραστείτε αρχεία μέσω BitTorrent
|
||||
Name[el]=qBittorrent
|
||||
Comment[en_GB]=Download and share files over BitTorrent
|
||||
GenericName[en_GB]=BitTorrent client
|
||||
Comment[en_GB]=Download and share files over BitTorrent
|
||||
Name[en_GB]=qBittorrent
|
||||
Comment[es]=Descargue y comparta archivos por BitTorrent
|
||||
GenericName[es]=Cliente BitTorrent
|
||||
Comment[es]=Descargue y comparta archivos por BitTorrent
|
||||
Name[es]=qBittorrent
|
||||
Comment[et]=Lae alla ja jaga faile üle BitTorrenti
|
||||
GenericName[et]=BitTorrent klient
|
||||
Comment[et]=Lae alla ja jaga faile üle BitTorrenti
|
||||
Name[et]=qBittorrent
|
||||
Comment[eu]=Jeitsi eta elkarbanatu agiriak BitTorrent bidez
|
||||
GenericName[eu]=BitTorrent bezeroa
|
||||
Comment[eu]=Jeitsi eta elkarbanatu agiriak BitTorrent bidez
|
||||
Name[eu]=qBittorrent
|
||||
Comment[fa]=دانلود و به اشتراک گذاری فایل های بوسیله بیت تورنت
|
||||
GenericName[fa]=بیت تورنت نسخه کلاینت
|
||||
Comment[fa]=دانلود و به اشتراک گذاری فایل های بوسیله بیت تورنت
|
||||
Name[fa]=qBittorrent
|
||||
Comment[fi]=Lataa ja jaa tiedostoja BitTorrentia käyttäen
|
||||
GenericName[fi]=BitTorrent-asiakasohjelma
|
||||
Comment[fi]=Lataa ja jaa tiedostoja BitTorrentia käyttäen
|
||||
Name[fi]=qBittorrent
|
||||
Comment[fr]=Télécharger et partager des fichiers sur BitTorrent
|
||||
GenericName[fr]=Client BitTorrent
|
||||
Comment[fr]=Télécharger et partager des fichiers sur BitTorrent
|
||||
Name[fr]=qBittorrent
|
||||
Comment[gl]=Descargar e compartir ficheiros co protocolo BitTorrent
|
||||
GenericName[gl]=Cliente BitTorrent
|
||||
Comment[gl]=Descargar e compartir ficheiros co protocolo BitTorrent
|
||||
Name[gl]=qBittorrent
|
||||
Comment[gu]=બિટ્ટોરેંટ પર ફાઈલો ડાઉનલોડ અને શેર કરો
|
||||
GenericName[gu]=બિટ્ટોરેંટ ક્લાયન્ટ
|
||||
Comment[gu]=બિટ્ટોરેંટ પર ફાઈલો ડાઉનલોડ અને શેર કરો
|
||||
Name[gu]=qBittorrent
|
||||
Comment[he]=הורד ושתף קבצים על גבי ביטורנט
|
||||
GenericName[he]=לקוח ביטורנט
|
||||
Comment[he]=הורד ושתף קבצים על גבי ביטורנט
|
||||
Name[he]=qBittorrent
|
||||
Comment[hr]=Preuzmite i dijelite datoteke putem BitTorrenta
|
||||
GenericName[hr]=BitTorrent klijent
|
||||
Comment[hr]=Preuzmite i dijelite datoteke putem BitTorrenta
|
||||
Name[hr]=qBittorrent
|
||||
Comment[hu]=Fájlok letöltése és megosztása a BitTorrent hálózaton keresztül
|
||||
GenericName[hu]=BitTorrent kliens
|
||||
Comment[hu]=Fájlok letöltése és megosztása a BitTorrent hálózaton keresztül
|
||||
Name[hu]=qBittorrent
|
||||
Comment[hy]=Նիշքերի փոխանցում BitTorrent-ի միջոցով
|
||||
GenericName[hy]=BitTorrent սպասառու
|
||||
Comment[hy]=Նիշքերի փոխանցում BitTorrent-ի միջոցով
|
||||
Name[hy]=qBittorrent
|
||||
Comment[id]=Unduh dan berbagi berkas melalui BitTorrent
|
||||
GenericName[id]=Klien BitTorrent
|
||||
Comment[id]=Unduh dan berbagi berkas melalui BitTorrent
|
||||
Name[id]=qBittorrent
|
||||
Comment[is]=Sækja og deila skrám yfir BitTorrent
|
||||
GenericName[is]=BitTorrent biðlarar
|
||||
Comment[is]=Sækja og deila skrám yfir BitTorrent
|
||||
Name[is]=qBittorrent
|
||||
Comment[it]=Scarica e condividi file tramite BitTorrent
|
||||
GenericName[it]=Client BitTorrent
|
||||
Comment[it]=Scarica e condividi file tramite BitTorrent
|
||||
Name[it]=qBittorrent
|
||||
Comment[ja]=BitTorrentでファイルのダウンロードと共有
|
||||
GenericName[ja]=BitTorrentクライアント
|
||||
Comment[ja]=BitTorrentでファイルのダウンロードと共有
|
||||
Name[ja]=qBittorrent
|
||||
Comment[ka]=გადმოტვირთეთ და გააზიარეთ ფაილები BitTorrent-ის საშუალებით
|
||||
GenericName[ka]=BitTorrent კლიენტი
|
||||
Comment[ka]=გადმოტვირთეთ და გააზიარეთ ფაილები BitTorrent-ის საშუალებით
|
||||
Name[ka]=qBittorrent
|
||||
Comment[ko]=BitTorrent를 통한 파일 내려받기 및 공유
|
||||
GenericName[ko]=BitTorrent 클라이언트
|
||||
Comment[ko]=BitTorrent를 통해 파일 다운로드 및 공유
|
||||
Name[ko]=qBittorrent
|
||||
Comment[lt]=Atsisiųskite bei dalinkitės failais BitTorrent tinkle
|
||||
GenericName[lt]=BitTorrent klientas
|
||||
Comment[lt]=Atsisiųskite bei dalinkitės failais BitTorrent tinkle
|
||||
Name[lt]=qBittorrent
|
||||
Comment[mk]=Превземајте и споделувајте фајлови преку BitTorrent
|
||||
GenericName[mk]=BitTorrent клиент
|
||||
Comment[mk]=Превземајте и споделувајте фајлови преку BitTorrent
|
||||
Name[mk]=qBittorrent
|
||||
Comment[my]=တောရန့်ဖြင့်ဖိုင်များဒေါင်းလုဒ်ဆွဲရန်နှင့်မျှဝေရန်
|
||||
GenericName[my]=တောရန့်စီမံခန့်ခွဲသည့်အရာ
|
||||
Comment[my]=တောရန့်ဖြင့်ဖိုင်များဒေါင်းလုဒ်ဆွဲရန်နှင့်မျှဝေရန်
|
||||
Name[my]=qBittorrent
|
||||
Comment[nb]=Last ned og del filer over BitTorrent
|
||||
GenericName[nb]=BitTorrent-klient
|
||||
Comment[nb]=Last ned og del filer over BitTorrent
|
||||
Name[nb]=qBittorrent
|
||||
Comment[nl]=Bestanden downloaden en delen via BitTorrent
|
||||
GenericName[nl]=BitTorrent-client
|
||||
Comment[nl]=Bestanden downloaden en delen via BitTorrent
|
||||
Name[nl]=qBittorrent
|
||||
Comment[pl]=Pobieraj i dziel się plikami przez BitTorrent
|
||||
GenericName[pl]=Klient BitTorrent
|
||||
Comment[pl]=Pobieraj i dziel się plikami przez BitTorrent
|
||||
Name[pl]=qBittorrent
|
||||
Comment[pt]=Transferir e partilhar ficheiros por BitTorrent
|
||||
GenericName[pt]=Cliente BitTorrent
|
||||
Comment[pt]=Transferir e partilhar ficheiros por BitTorrent
|
||||
Name[pt]=qBittorrent
|
||||
Comment[pt_BR]=Baixe e compartilhe arquivos pelo BitTorrent
|
||||
GenericName[pt_BR]=Cliente BitTorrent
|
||||
Comment[pt_BR]=Baixe e compartilhe arquivos pelo BitTorrent
|
||||
Name[pt_BR]=qBittorrent
|
||||
Comment[ro]=Descărcați și partajați fișiere prin BitTorrent
|
||||
GenericName[ro]=Client BitTorrent
|
||||
Comment[ro]=Descărcați și partajați fișiere prin BitTorrent
|
||||
Name[ro]=qBittorrent
|
||||
Comment[ru]=Обмен файлами по сети БитТоррент
|
||||
GenericName[ru]=Клиент сети БитТоррент
|
||||
Comment[ru]=Обмен файлами по сети БитТоррент
|
||||
Name[ru]=qBittorrent
|
||||
Comment[sk]=Sťahovanie a zdieľanie súborov prostredníctvom siete BitTorrent
|
||||
GenericName[sk]=Klient siete BitTorrent
|
||||
Comment[sk]=Sťahovanie a zdieľanie súborov prostredníctvom siete BitTorrent
|
||||
Name[sk]=qBittorrent
|
||||
Comment[sl]=Prenesite in delite datoteke preko BitTorrenta
|
||||
GenericName[sl]=BitTorrent odjemalec
|
||||
Comment[sl]=Prenesite in delite datoteke preko BitTorrenta
|
||||
Name[sl]=qBittorrent
|
||||
GenericName[sq]=Klienti BitTorrent
|
||||
Comment[sq]=Shkarko dhe shpërndaj skedarë në BitTorrent
|
||||
Name[sq]=qBittorrent
|
||||
Comment[sr]=Преузимајте и делите фајлове преко BitTorrent протокола
|
||||
GenericName[sr]=BitTorrent-клијент
|
||||
GenericName[sr]=BitTorrent клијент
|
||||
Comment[sr]=Преузимајте и делите фајлове преко BitTorrent-а
|
||||
Name[sr]=qBittorrent
|
||||
Comment[sr@latin]=Preuzimanje i deljenje fajlova preko BitTorrent-a
|
||||
GenericName[sr@latin]=BitTorrent klijent
|
||||
Comment[sr@latin]=Preuzimanje i deljenje fajlova preko BitTorrent-a
|
||||
Name[sr@latin]=qBittorrent
|
||||
Comment[sv]=Hämta och dela filer över BitTorrent
|
||||
GenericName[sv]=BitTorrent-klient
|
||||
Comment[sv]=Hämta och dela filer över BitTorrent
|
||||
Name[sv]=qBittorrent
|
||||
Comment[ta]=BitTorrent வழியாக கோப்புகளை பதிவிறக்க மற்றும் பகிர
|
||||
GenericName[ta]=BitTorrent வாடிக்கையாளர்
|
||||
Comment[ta]=BitTorrent வழியாக கோப்புகளை பதிவிறக்க மற்றும் பகிர
|
||||
Name[ta]=qBittorrent
|
||||
Comment[te]=క్యు బిట్ టొరెంట్ తో ఫైల్స్ దిగుమతి చేసుకోండి , పంచుకోండి
|
||||
GenericName[te]=క్యు బిట్ టొరెంట్ క్లయింట్
|
||||
Comment[te]=క్యు బిట్ టొరెంట్ తో ఫైల్స్ దిగుమతి చేసుకోండి , పంచుకోండి
|
||||
Name[te]=qBittorrent
|
||||
Comment[th]=ดาวน์โหลดและแชร์ไฟล์ผ่าน BitTorrent
|
||||
GenericName[th]=โปรแกรมบิททอเร้นท์
|
||||
GenericName[th]=ไคลเอนต์บิททอร์เรนต์
|
||||
Comment[th]=ดาวน์โหลดและแชร์ไฟล์ผ่านบิตทอร์เรนต์
|
||||
Name[th]=qBittorrent
|
||||
Comment[tr]=Dosyaları BitTorrent üzerinden indirin ve paylaşın
|
||||
GenericName[tr]=BitTorrent istemcisi
|
||||
Comment[tr]=Dosyaları BitTorrent üzerinden indirin ve paylaşın
|
||||
Name[tr]=qBittorrent
|
||||
Comment[ur]=BitTorrent پر فائلوں کو ڈاؤن لوڈ کریں اور اشتراک کریں
|
||||
GenericName[ur]=قیو بٹ ٹورنٹ کلائنٹ
|
||||
Comment[ur]=BitTorrent پر فائلوں کو ڈاؤن لوڈ کریں اور اشتراک کریں
|
||||
Name[ur]=qBittorrent
|
||||
Comment[uk]=Завантажуйте та поширюйте файли через BitTorrent
|
||||
GenericName[uk]=BitTorrent-клієнт
|
||||
Comment[uk]=Завантажуйте та поширюйте файли через BitTorrent
|
||||
Name[uk]=qBittorrent
|
||||
Comment[vi]=Tải xuống và chia sẻ tệp qua BitTorrent
|
||||
GenericName[vi]=Máy khách BitTorrent
|
||||
Comment[vi]=Tải xuống và chia sẻ tệp qua BitTorrent
|
||||
Name[vi]=qBittorrent
|
||||
Comment[zh_HK]=經由BitTorrent下載並分享檔案
|
||||
GenericName[zh_HK]=BitTorrent用戶端
|
||||
Comment[zh_HK]=經由BitTorrent下載並分享檔案
|
||||
Name[zh_HK]=qBittorrent
|
||||
Comment[zh_TW]=經由 BitTorrent 下載並分享檔案
|
||||
GenericName[zh_TW]=BitTorrent 用戶端
|
||||
Comment[zh_TW]=使用 BitTorrent 下載並分享檔案
|
||||
Name[zh_TW]=qBittorrent
|
||||
Comment[eo]=Elŝutu kaj kunhavigu dosierojn per BitTorrent
|
||||
GenericName[eo]=BitTorrent-kliento
|
||||
Comment[eo]=Elŝutu kaj kunhavigu dosierojn per BitTorrent
|
||||
Name[eo]=qBittorrent
|
||||
Comment[kk]=BitTorrent арқылы файл жүктеу және бөлісу
|
||||
GenericName[kk]=BitTorrent клиенті
|
||||
Comment[kk]=BitTorrent арқылы файл жүктеу және бөлісу
|
||||
Name[kk]=qBittorrent
|
||||
Comment[en_AU]=Download and share files over BitTorrent
|
||||
GenericName[en_AU]=BitTorrent client
|
||||
Comment[en_AU]=Download and share files over BitTorrent
|
||||
Name[en_AU]=qBittorrent
|
||||
Name[rm]=qBittorrent
|
||||
Name[jv]=qBittorrent
|
||||
Comment[oc]=Telecargar e partejar de fichièrs amb BitTorrent
|
||||
GenericName[oc]=Client BitTorrent
|
||||
Comment[oc]=Telecargar e partejar de fichièrs amb BitTorrent
|
||||
Name[oc]=qBittorrent
|
||||
Name[ug]=qBittorrent
|
||||
Name[yi]=qBittorrent
|
||||
Comment[nqo]=ߞߐߕߐ߯ߘߐ ߟߎ߬ ߟߊߖߌ߰ ߞߊ߬ ߓߊ߲߫ ߞߵߊ߬ߟߎ߬ ߘߐߕߟߊ߫ ߓߌߙߏߙߍ߲ߕ ߞߊ߲߬
|
||||
GenericName[nqo]=ߓߌߙߏߙߍ߲ߕ ߕߣߐ߬ߓߐ߬ߟߊ
|
||||
Comment[nqo]=ߞߐߕߐ߯ߘߐ ߟߎ߬ ߟߊߖߌ߰ ߞߊ߬ ߓߊ߲߫ ߞߵߊ߬ߟߎ߬ ߘߐߕߟߊ߫ ߓߌߙߏߙߍ߲ߕ ߞߊ߲߬
|
||||
Name[nqo]=qBittorrent
|
||||
Comment[uz@Latn]=BitTorrent orqali fayllarni yuklab olish va baham ko‘rish
|
||||
GenericName[uz@Latn]=BitTorrent mijozi
|
||||
Comment[uz@Latn]=BitTorrent orqali fayllarni yuklab olish va baham ko‘rish
|
||||
Name[uz@Latn]=qBittorrent
|
||||
Comment[ltg]=Atsasyuteit i daleit failus ar BitTorrent
|
||||
GenericName[ltg]=BitTorrent klients
|
||||
Comment[ltg]=Atsasyuteit i daleit failus ar BitTorrent
|
||||
Name[ltg]=qBittorrent
|
||||
Comment[hi_IN]=BitTorrent द्वारा फाइल डाउनलोड व सहभाजन
|
||||
GenericName[hi_IN]=Bittorrent साधन
|
||||
Comment[hi_IN]=BitTorrent द्वारा फाइल डाउनलोड व सहभाजन
|
||||
Name[hi_IN]=qBittorrent
|
||||
Comment[az@latin]=Faylları BitTorrent vasitəsilə endirin və paylaşın
|
||||
GenericName[az@latin]=BitTorrent client
|
||||
Comment[az@latin]=Faylları BitTorrent vasitəsilə endirin və paylaşın
|
||||
Name[az@latin]=qBittorrent
|
||||
Comment[lv_LV]=Lejupielādēt un koplietot failus ar BitTorrent
|
||||
GenericName[lv_LV]=BitTorrent klients
|
||||
Comment[lv_LV]=Lejupielādēt un koplietot failus ar BitTorrent
|
||||
Name[lv_LV]=qBittorrent
|
||||
Comment[ms_MY]=Muat turun dan kongsi fail melalui BitTorrent
|
||||
GenericName[ms_MY]=Klien BitTorrent
|
||||
Comment[ms_MY]=Muat turun dan kongsi fail melalui BitTorrent
|
||||
Name[ms_MY]=qBittorrent
|
||||
Comment[mn_MN]=BitTorrent-оор файлуудаа тат, түгээ
|
||||
GenericName[mn_MN]=BitTorrent татагч
|
||||
Comment[mn_MN]=BitTorrent-оор файлуудаа тат, түгээ
|
||||
Name[mn_MN]=qBittorrent
|
||||
Comment[ne_NP]=फाइलहरू डाउनलोड गर्नुहोस् र BitTorrent मा साझा गर्नुहोस्
|
||||
GenericName[ne_NP]=BitTorrent क्लाइन्ट
|
||||
Comment[ne_NP]=फाइलहरू डाउनलोड गर्नुहोस् र BitTorrent मा साझा गर्नुहोस्
|
||||
Name[ne_NP]=qBittorrent
|
||||
Comment[pt_PT]=Transferir e partilhar ficheiros por BitTorrent
|
||||
GenericName[pt_PT]=Cliente BitTorrent
|
||||
Comment[pt_PT]=Transferir e partilhar ficheiros por BitTorrent
|
||||
Name[pt_PT]=qBittorrent
|
||||
GenericName[si_LK]=BitTorrent සේවාදායකයා
|
||||
Comment[si_LK]=BitTorrent හරහා ගොනු බාගත කර බෙදාගන්න.
|
||||
Name[si_LK]=qBittorrent
|
||||
|
|
|
@ -62,6 +62,6 @@
|
|||
<url type="contribute">https://github.com/qbittorrent/qBittorrent/blob/master/CONTRIBUTING.md</url>
|
||||
<content_rating type="oars-1.1"/>
|
||||
<releases>
|
||||
<release version="5.1.0~beta1" date="2024-12-16"/>
|
||||
<release version="5.2.0~alpha1" date="2025-02-11"/>
|
||||
</releases>
|
||||
</component>
|
||||
|
|
4
dist/windows/config.nsh
vendored
4
dist/windows/config.nsh
vendored
|
@ -14,7 +14,7 @@
|
|||
; 4.5.1.3 -> good
|
||||
; 4.5.1.3.2 -> bad
|
||||
; 4.5.0beta -> bad
|
||||
!define /ifndef QBT_VERSION "5.1.0"
|
||||
!define /ifndef QBT_VERSION "5.2.0"
|
||||
|
||||
; Option that controls the installer's window name
|
||||
; If set, its value will be used like this:
|
||||
|
@ -86,7 +86,7 @@ OutFile "qbittorrent_${QBT_INSTALLER_FILENAME}_setup.exe"
|
|||
;Installer Version Information
|
||||
VIAddVersionKey "ProductName" "qBittorrent"
|
||||
VIAddVersionKey "CompanyName" "The qBittorrent project"
|
||||
VIAddVersionKey "LegalCopyright" "Copyright ©2006-2024 The qBittorrent project"
|
||||
VIAddVersionKey "LegalCopyright" "Copyright ©2006-2025 The qBittorrent project"
|
||||
VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client"
|
||||
VIAddVersionKey "FileVersion" "${QBT_VERSION}"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ LangString inst_desktop ${LANG_PORTUGUESE} "Criar atalho no ambiente de trabalho
|
|||
;LangString inst_startmenu ${LANG_ENGLISH} "Create Start Menu Shortcut"
|
||||
LangString inst_startmenu ${LANG_PORTUGUESE} "Criar atalho no menu Iniciar"
|
||||
;LangString inst_startup ${LANG_ENGLISH} "Start qBittorrent on Windows start up"
|
||||
LangString inst_startup ${LANG_PORTUGUESE} "Iniciar o qBittorrent na inicialização do Windows"
|
||||
LangString inst_startup ${LANG_PORTUGUESE} "Iniciar o qBittorrent no arranque do Windows"
|
||||
;LangString inst_torrent ${LANG_ENGLISH} "Open .torrent files with qBittorrent"
|
||||
LangString inst_torrent ${LANG_PORTUGUESE} "Abrir ficheiros .torrent com o qBittorrent"
|
||||
;LangString inst_magnet ${LANG_ENGLISH} "Open magnet links with qBittorrent"
|
||||
|
@ -29,7 +29,7 @@ LangString launch_qbt ${LANG_PORTUGUESE} "Iniciar qBittorrent."
|
|||
;LangString inst_requires_64bit ${LANG_ENGLISH} "This installer works only in 64-bit Windows versions."
|
||||
LangString inst_requires_64bit ${LANG_PORTUGUESE} "Este instalador funciona apenas em versões Windows de 64 bits."
|
||||
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 (1809) / Windows Server 2019."
|
||||
LangString inst_requires_win10 ${LANG_PORTUGUESE} "This installer requires at least Windows 10 (1809) / Windows Server 2019."
|
||||
LangString inst_requires_win10 ${LANG_PORTUGUESE} "Este instalador requer, pelo menos, o Windows 10 (1809) / Windows Server 2019."
|
||||
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
|
||||
LangString inst_uninstall_link_description ${LANG_PORTUGUESE} "Desinstalar qBittorrent"
|
||||
|
||||
|
|
12
dist/windows/installer-translations/swedish.nsh
vendored
12
dist/windows/installer-translations/swedish.nsh
vendored
|
@ -7,21 +7,21 @@ LangString inst_desktop ${LANG_SWEDISH} "Skapa skrivbordsgenväg"
|
|||
;LangString inst_startmenu ${LANG_ENGLISH} "Create Start Menu Shortcut"
|
||||
LangString inst_startmenu ${LANG_SWEDISH} "Skapa startmenygenväg"
|
||||
;LangString inst_startup ${LANG_ENGLISH} "Start qBittorrent on Windows start up"
|
||||
LangString inst_startup ${LANG_SWEDISH} "Starta qBittorrent vid Windows start"
|
||||
LangString inst_startup ${LANG_SWEDISH} "Starta qBittorrent vid Windows-uppstart"
|
||||
;LangString inst_torrent ${LANG_ENGLISH} "Open .torrent files with qBittorrent"
|
||||
LangString inst_torrent ${LANG_SWEDISH} "Öppna .torrent-filer med qBittorrent"
|
||||
;LangString inst_magnet ${LANG_ENGLISH} "Open magnet links with qBittorrent"
|
||||
LangString inst_magnet ${LANG_SWEDISH} "Öppna magnetlänkar med qBittorrent"
|
||||
;LangString inst_firewall ${LANG_ENGLISH} "Add Windows Firewall rule"
|
||||
LangString inst_firewall ${LANG_SWEDISH} "Lägg till Windows-brandväggregel"
|
||||
LangString inst_firewall ${LANG_SWEDISH} "Lägg till Windows-brandväggsregel"
|
||||
;LangString inst_pathlimit ${LANG_ENGLISH} "Disable Windows path length limit (260 character MAX_PATH limitation, requires Windows 10 1607 or later)"
|
||||
LangString inst_pathlimit ${LANG_SWEDISH} "Inaktivera gränsen för Windows-sökvägslängd (260 tecken MAX_PATH-begränsning, kräver Windows 10 1607 eller senare)"
|
||||
;LangString inst_firewallinfo ${LANG_ENGLISH} "Adding Windows Firewall rule"
|
||||
LangString inst_firewallinfo ${LANG_SWEDISH} "Lägger till Windows-brandväggregel"
|
||||
LangString inst_firewallinfo ${LANG_SWEDISH} "Lägger till Windows-brandväggsregel"
|
||||
;LangString inst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before installing."
|
||||
LangString inst_warning ${LANG_SWEDISH} "qBittorrent körs. Vänligen stäng programmet innan du installerar."
|
||||
LangString inst_warning ${LANG_SWEDISH} "qBittorrent körs. Stäng programmet innan du installerar."
|
||||
;LangString inst_uninstall_question ${LANG_ENGLISH} "Current version will be uninstalled. User settings and torrents will remain intact."
|
||||
LangString inst_uninstall_question ${LANG_SWEDISH} "Nuvarande version avinstalleras. Användarinställningar och torrenter kommer att förbli intakta."
|
||||
LangString inst_uninstall_question ${LANG_SWEDISH} "Aktuell version avinstalleras. Användarinställningar och torrenter kommer att förbli intakta."
|
||||
;LangString inst_unist ${LANG_ENGLISH} "Uninstalling previous version."
|
||||
LangString inst_unist ${LANG_SWEDISH} "Avinstallerar tidigare version."
|
||||
;LangString launch_qbt ${LANG_ENGLISH} "Launch qBittorrent."
|
||||
|
@ -53,7 +53,7 @@ LangString remove_firewallinfo ${LANG_SWEDISH} "Tar bort Windows-brandväggsrege
|
|||
;LangString remove_cache ${LANG_ENGLISH} "Remove torrents and cached data"
|
||||
LangString remove_cache ${LANG_SWEDISH} "Ta bort torrenter och cachade data"
|
||||
;LangString uninst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before uninstalling."
|
||||
LangString uninst_warning ${LANG_SWEDISH} "qBittorrent körs. Vänligen stäng programmet innan du avinstallerar."
|
||||
LangString uninst_warning ${LANG_SWEDISH} "qBittorrent körs. Stäng programmet innan du avinstallerar."
|
||||
;LangString uninst_tor_warn ${LANG_ENGLISH} "Not removing .torrent association. It is associated with:"
|
||||
LangString uninst_tor_warn ${LANG_SWEDISH} "Tar inte bort .torrent-association. Den är associerad med:"
|
||||
;LangString uninst_mag_warn ${LANG_ENGLISH} "Not removing magnet association. It is associated with:"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -124,6 +124,28 @@ namespace
|
|||
const int PIXMAP_CACHE_SIZE = 64 * 1024 * 1024; // 64MiB
|
||||
#endif
|
||||
|
||||
const QString PARAM_ADDSTOPPED = u"@addStopped"_s;
|
||||
const QString PARAM_CATEGORY = u"@category"_s;
|
||||
const QString PARAM_FIRSTLASTPIECEPRIORITY = u"@firstLastPiecePriority"_s;
|
||||
const QString PARAM_SAVEPATH = u"@savePath"_s;
|
||||
const QString PARAM_SEQUENTIAL = u"@sequential"_s;
|
||||
const QString PARAM_SKIPCHECKING = u"@skipChecking"_s;
|
||||
const QString PARAM_SKIPDIALOG = u"@skipDialog"_s;
|
||||
|
||||
QString bindParamValue(const QStringView paramName, const QStringView paramValue)
|
||||
{
|
||||
return paramName + u'=' + paramValue;
|
||||
}
|
||||
|
||||
std::pair<QStringView, QStringView> parseParam(const QStringView param)
|
||||
{
|
||||
const qsizetype sepIndex = param.indexOf(u'=');
|
||||
if (sepIndex >= 0)
|
||||
return {param.first(sepIndex), param.sliced(sepIndex + 1)};
|
||||
|
||||
return {param, {}};
|
||||
}
|
||||
|
||||
QString serializeParams(const QBtCommandLineParameters ¶ms)
|
||||
{
|
||||
QStringList result;
|
||||
|
@ -138,85 +160,86 @@ namespace
|
|||
const BitTorrent::AddTorrentParams &addTorrentParams = params.addTorrentParams;
|
||||
|
||||
if (!addTorrentParams.savePath.isEmpty())
|
||||
result.append(u"@savePath=" + addTorrentParams.savePath.data());
|
||||
result.append(bindParamValue(PARAM_SAVEPATH, addTorrentParams.savePath.data()));
|
||||
|
||||
if (addTorrentParams.addStopped.has_value())
|
||||
result.append(*addTorrentParams.addStopped ? u"@addStopped=1"_s : u"@addStopped=0"_s);
|
||||
result.append(bindParamValue(PARAM_ADDSTOPPED, (*addTorrentParams.addStopped ? u"1" : u"0")));
|
||||
|
||||
if (addTorrentParams.skipChecking)
|
||||
result.append(u"@skipChecking"_s);
|
||||
result.append(PARAM_SKIPCHECKING);
|
||||
|
||||
if (!addTorrentParams.category.isEmpty())
|
||||
result.append(u"@category=" + addTorrentParams.category);
|
||||
result.append(bindParamValue(PARAM_CATEGORY, addTorrentParams.category));
|
||||
|
||||
if (addTorrentParams.sequential)
|
||||
result.append(u"@sequential"_s);
|
||||
result.append(PARAM_SEQUENTIAL);
|
||||
|
||||
if (addTorrentParams.firstLastPiecePriority)
|
||||
result.append(u"@firstLastPiecePriority"_s);
|
||||
result.append(PARAM_FIRSTLASTPIECEPRIORITY);
|
||||
|
||||
if (params.skipDialog.has_value())
|
||||
result.append(*params.skipDialog ? u"@skipDialog=1"_s : u"@skipDialog=0"_s);
|
||||
result.append(bindParamValue(PARAM_SKIPDIALOG, (*params.skipDialog ? u"1" : u"0")));
|
||||
|
||||
result += params.torrentSources;
|
||||
|
||||
return result.join(PARAMS_SEPARATOR);
|
||||
}
|
||||
|
||||
QBtCommandLineParameters parseParams(const QString &str)
|
||||
QBtCommandLineParameters parseParams(const QStringView str)
|
||||
{
|
||||
QBtCommandLineParameters parsedParams;
|
||||
BitTorrent::AddTorrentParams &addTorrentParams = parsedParams.addTorrentParams;
|
||||
|
||||
for (QString param : asConst(str.split(PARAMS_SEPARATOR, Qt::SkipEmptyParts)))
|
||||
for (QStringView param : asConst(str.split(PARAMS_SEPARATOR, Qt::SkipEmptyParts)))
|
||||
{
|
||||
param = param.trimmed();
|
||||
const auto [paramName, paramValue] = parseParam(param);
|
||||
|
||||
// Process strings indicating options specified by the user.
|
||||
|
||||
if (param.startsWith(u"@savePath="))
|
||||
if (paramName == PARAM_SAVEPATH)
|
||||
{
|
||||
addTorrentParams.savePath = Path(param.mid(10));
|
||||
addTorrentParams.savePath = Path(paramValue.toString());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param.startsWith(u"@addStopped="))
|
||||
if (paramName == PARAM_ADDSTOPPED)
|
||||
{
|
||||
addTorrentParams.addStopped = (QStringView(param).mid(11).toInt() != 0);
|
||||
addTorrentParams.addStopped = (paramValue.toInt() != 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param == u"@skipChecking")
|
||||
if (paramName == PARAM_SKIPCHECKING)
|
||||
{
|
||||
addTorrentParams.skipChecking = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param.startsWith(u"@category="))
|
||||
if (paramName == PARAM_CATEGORY)
|
||||
{
|
||||
addTorrentParams.category = param.mid(10);
|
||||
addTorrentParams.category = paramValue.toString();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param == u"@sequential")
|
||||
if (paramName == PARAM_SEQUENTIAL)
|
||||
{
|
||||
addTorrentParams.sequential = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param == u"@firstLastPiecePriority")
|
||||
if (paramName == PARAM_FIRSTLASTPIECEPRIORITY)
|
||||
{
|
||||
addTorrentParams.firstLastPiecePriority = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (param.startsWith(u"@skipDialog="))
|
||||
if (paramName == PARAM_SKIPDIALOG)
|
||||
{
|
||||
parsedParams.skipDialog = (QStringView(param).mid(12).toInt() != 0);
|
||||
parsedParams.skipDialog = (paramValue.toInt() != 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
parsedParams.torrentSources.append(param);
|
||||
parsedParams.torrentSources.append(param.toString());
|
||||
}
|
||||
|
||||
return parsedParams;
|
||||
|
@ -579,7 +602,7 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
|||
const QString logMsg = tr("Running external program. Torrent: \"%1\". Command: `%2`");
|
||||
const QString logMsgError = tr("Failed to run external program. Torrent: \"%1\". Command: `%2`");
|
||||
|
||||
// The processing sequenece is different for Windows and other OS, this is intentional
|
||||
// The processing sequence is different for Windows and other OS, this is intentional
|
||||
#if defined(Q_OS_WIN)
|
||||
const QString program = replaceVariables(programTemplate);
|
||||
const std::wstring programWStr = program.toStdWString();
|
||||
|
@ -636,7 +659,13 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
|||
{
|
||||
// strip redundant quotes
|
||||
if (arg.startsWith(u'"') && arg.endsWith(u'"'))
|
||||
arg = arg.mid(1, (arg.size() - 2));
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
arg.slice(1, (arg.size() - 2));
|
||||
#else
|
||||
arg.removeLast().removeFirst();
|
||||
#endif
|
||||
}
|
||||
|
||||
arg = replaceVariables(arg);
|
||||
}
|
||||
|
@ -645,6 +674,9 @@ void Application::runExternalProgram(const QString &programTemplate, const BitTo
|
|||
QProcess proc;
|
||||
proc.setProgram(command);
|
||||
proc.setArguments(args);
|
||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
proc.setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||
#endif
|
||||
|
||||
if (proc.startDetached())
|
||||
{
|
||||
|
@ -897,10 +929,10 @@ int Application::exec()
|
|||
m_desktopIntegration->showNotification(tr("Torrent added"), tr("'%1' was added.", "e.g: xxx.avi was added.").arg(torrent->name()));
|
||||
});
|
||||
connect(m_addTorrentManager, &AddTorrentManager::addTorrentFailed, this
|
||||
, [this](const QString &source, const QString &reason)
|
||||
, [this](const QString &source, const BitTorrent::AddTorrentError &reason)
|
||||
{
|
||||
m_desktopIntegration->showNotification(tr("Add torrent failed")
|
||||
, tr("Couldn't add torrent '%1', reason: %2.").arg(source, reason));
|
||||
, tr("Couldn't add torrent '%1', reason: %2.").arg(source, reason.message));
|
||||
});
|
||||
|
||||
disconnect(m_desktopIntegration, &DesktopIntegration::activationRequested, this, &Application::createStartupProgressDialog);
|
||||
|
|
|
@ -465,13 +465,13 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
|
|||
return result;
|
||||
}
|
||||
|
||||
QString wrapText(const QString &text, int initialIndentation = USAGE_TEXT_COLUMN, int wrapAtColumn = WRAP_AT_COLUMN)
|
||||
QString wrapText(const QString &text, const int initialIndentation = USAGE_TEXT_COLUMN, const int wrapAtColumn = WRAP_AT_COLUMN)
|
||||
{
|
||||
QStringList words = text.split(u' ');
|
||||
const QStringList words = text.split(u' ');
|
||||
QStringList lines = {words.first()};
|
||||
int currentLineMaxLength = wrapAtColumn - initialIndentation;
|
||||
|
||||
for (const QString &word : asConst(words.mid(1)))
|
||||
for (const QString &word : asConst(words.sliced(1)))
|
||||
{
|
||||
if (lines.last().length() + word.length() + 1 < currentLineMaxLength)
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ add_library(qbt_base STATIC
|
|||
applicationcomponent.h
|
||||
asyncfilestorage.h
|
||||
bittorrent/abstractfilestorage.h
|
||||
bittorrent/addtorrenterror.h
|
||||
bittorrent/addtorrentparams.h
|
||||
bittorrent/announcetimepoint.h
|
||||
bittorrent/bandwidthscheduler.h
|
||||
|
@ -54,6 +55,7 @@ add_library(qbt_base STATIC
|
|||
concepts/stringable.h
|
||||
digest32.h
|
||||
exceptions.h
|
||||
freediskspacechecker.h
|
||||
global.h
|
||||
http/connection.h
|
||||
http/httperror.h
|
||||
|
@ -159,6 +161,7 @@ add_library(qbt_base STATIC
|
|||
bittorrent/trackerentry.cpp
|
||||
bittorrent/trackerentrystatus.cpp
|
||||
exceptions.cpp
|
||||
freediskspacechecker.cpp
|
||||
http/connection.cpp
|
||||
http/httperror.cpp
|
||||
http/requestparser.cpp
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "addtorrentmanager.h"
|
||||
|
||||
#include "base/bittorrent/addtorrenterror.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrentdescriptor.h"
|
||||
|
@ -140,7 +141,7 @@ void AddTorrentManager::onSessionTorrentAdded(BitTorrent::Torrent *torrent)
|
|||
}
|
||||
}
|
||||
|
||||
void AddTorrentManager::onSessionAddTorrentFailed(const BitTorrent::InfoHash &infoHash, const QString &reason)
|
||||
void AddTorrentManager::onSessionAddTorrentFailed(const BitTorrent::InfoHash &infoHash, const BitTorrent::AddTorrentError &reason)
|
||||
{
|
||||
if (const QString source = m_sourcesByInfoHash.take(infoHash); !source.isEmpty())
|
||||
{
|
||||
|
@ -154,7 +155,7 @@ void AddTorrentManager::onSessionAddTorrentFailed(const BitTorrent::InfoHash &in
|
|||
void AddTorrentManager::handleAddTorrentFailed(const QString &source, const QString &reason)
|
||||
{
|
||||
LogMsg(tr("Failed to add torrent. Source: \"%1\". Reason: \"%2\"").arg(source, reason), Log::WARNING);
|
||||
emit addTorrentFailed(source, reason);
|
||||
emit addTorrentFailed(source, {BitTorrent::AddTorrentError::Other, reason});
|
||||
}
|
||||
|
||||
void AddTorrentManager::handleDuplicateTorrent(const QString &source
|
||||
|
@ -185,9 +186,9 @@ void AddTorrentManager::handleDuplicateTorrent(const QString &source
|
|||
message = tr("Trackers are merged from new source");
|
||||
}
|
||||
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Source: %1. Existing torrent: %2. Result: %3")
|
||||
.arg(source, existingTorrent->name(), message));
|
||||
emit addTorrentFailed(source, message);
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Source: %1. Existing torrent: \"%2\". Torrent infohash: %3. Result: %4")
|
||||
.arg(source, existingTorrent->name(), existingTorrent->infoHash().toString(), message));
|
||||
emit addTorrentFailed(source, {BitTorrent::AddTorrentError::DuplicateTorrent, message});
|
||||
}
|
||||
|
||||
void AddTorrentManager::setTorrentFileGuard(const QString &source, std::shared_ptr<TorrentFileGuard> torrentFileGuard)
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace BitTorrent
|
|||
class Session;
|
||||
class Torrent;
|
||||
class TorrentDescriptor;
|
||||
struct AddTorrentError;
|
||||
}
|
||||
|
||||
namespace Net
|
||||
|
@ -66,7 +67,7 @@ public:
|
|||
|
||||
signals:
|
||||
void torrentAdded(const QString &source, BitTorrent::Torrent *torrent);
|
||||
void addTorrentFailed(const QString &source, const QString &reason);
|
||||
void addTorrentFailed(const QString &source, const BitTorrent::AddTorrentError &reason);
|
||||
|
||||
protected:
|
||||
bool addTorrentToSession(const QString &source, const BitTorrent::TorrentDescriptor &torrentDescr
|
||||
|
@ -79,7 +80,7 @@ protected:
|
|||
private:
|
||||
void onDownloadFinished(const Net::DownloadResult &result);
|
||||
void onSessionTorrentAdded(BitTorrent::Torrent *torrent);
|
||||
void onSessionAddTorrentFailed(const BitTorrent::InfoHash &infoHash, const QString &reason);
|
||||
void onSessionAddTorrentFailed(const BitTorrent::InfoHash &infoHash, const BitTorrent::AddTorrentError &reason);
|
||||
bool processTorrent(const QString &source, const BitTorrent::TorrentDescriptor &torrentDescr
|
||||
, const BitTorrent::AddTorrentParams &addTorrentParams);
|
||||
|
||||
|
|
49
src/base/bittorrent/addtorrenterror.h
Normal file
49
src/base/bittorrent/addtorrenterror.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
struct AddTorrentError
|
||||
{
|
||||
enum Kind
|
||||
{
|
||||
DuplicateTorrent,
|
||||
Other
|
||||
};
|
||||
|
||||
Kind kind = Other;
|
||||
QString message;
|
||||
};
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(BitTorrent::AddTorrentError)
|
|
@ -290,6 +290,8 @@ BitTorrent::LoadResumeDataResult BitTorrent::BencodeResumeDataStorage::loadTorre
|
|||
lt::add_torrent_params &p = torrentParams.ltAddTorrentParams;
|
||||
|
||||
p = lt::read_resume_data(resumeDataRoot, ec);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse resume data: %1").arg(QString::fromStdString(ec.message())));
|
||||
|
||||
if (!metadata.isEmpty())
|
||||
{
|
||||
|
@ -320,6 +322,8 @@ BitTorrent::LoadResumeDataResult BitTorrent::BencodeResumeDataStorage::loadTorre
|
|||
|
||||
p.save_path = Profile::instance()->fromPortablePath(
|
||||
Path(fromLTString(p.save_path))).toString().toStdString();
|
||||
if (p.save_path.empty())
|
||||
return nonstd::make_unexpected(tr("Corrupted resume data: %1").arg(tr("save_path is invalid")));
|
||||
|
||||
torrentParams.stopped = (p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
||||
torrentParams.operatingMode = (p.flags & lt::torrent_flags::paused) || (p.flags & lt::torrent_flags::auto_managed)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2021-2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2021-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -217,80 +217,6 @@ namespace
|
|||
{
|
||||
return u"%1 %2"_s.arg(quoted(column.name), definition);
|
||||
}
|
||||
|
||||
LoadTorrentParams parseQueryResultRow(const QSqlQuery &query)
|
||||
{
|
||||
LoadTorrentParams resumeData;
|
||||
resumeData.name = query.value(DB_COLUMN_NAME.name).toString();
|
||||
resumeData.category = query.value(DB_COLUMN_CATEGORY.name).toString();
|
||||
const QString tagsData = query.value(DB_COLUMN_TAGS.name).toString();
|
||||
if (!tagsData.isEmpty())
|
||||
{
|
||||
const QStringList tagList = tagsData.split(u',');
|
||||
resumeData.tags.insert(tagList.cbegin(), tagList.cend());
|
||||
}
|
||||
resumeData.hasFinishedStatus = query.value(DB_COLUMN_HAS_SEED_STATUS.name).toBool();
|
||||
resumeData.firstLastPiecePriority = query.value(DB_COLUMN_HAS_OUTER_PIECES_PRIORITY.name).toBool();
|
||||
resumeData.ratioLimit = query.value(DB_COLUMN_RATIO_LIMIT.name).toInt() / 1000.0;
|
||||
resumeData.seedingTimeLimit = query.value(DB_COLUMN_SEEDING_TIME_LIMIT.name).toInt();
|
||||
resumeData.inactiveSeedingTimeLimit = query.value(DB_COLUMN_INACTIVE_SEEDING_TIME_LIMIT.name).toInt();
|
||||
resumeData.shareLimitAction = Utils::String::toEnum<ShareLimitAction>(
|
||||
query.value(DB_COLUMN_SHARE_LIMIT_ACTION.name).toString(), ShareLimitAction::Default);
|
||||
resumeData.contentLayout = Utils::String::toEnum<TorrentContentLayout>(
|
||||
query.value(DB_COLUMN_CONTENT_LAYOUT.name).toString(), TorrentContentLayout::Original);
|
||||
resumeData.operatingMode = Utils::String::toEnum<TorrentOperatingMode>(
|
||||
query.value(DB_COLUMN_OPERATING_MODE.name).toString(), TorrentOperatingMode::AutoManaged);
|
||||
resumeData.stopped = query.value(DB_COLUMN_STOPPED.name).toBool();
|
||||
resumeData.stopCondition = Utils::String::toEnum(
|
||||
query.value(DB_COLUMN_STOP_CONDITION.name).toString(), Torrent::StopCondition::None);
|
||||
resumeData.sslParameters =
|
||||
{
|
||||
.certificate = QSslCertificate(query.value(DB_COLUMN_SSL_CERTIFICATE.name).toByteArray()),
|
||||
.privateKey = Utils::SSLKey::load(query.value(DB_COLUMN_SSL_PRIVATE_KEY.name).toByteArray()),
|
||||
.dhParams = query.value(DB_COLUMN_SSL_DH_PARAMS.name).toByteArray()
|
||||
};
|
||||
|
||||
resumeData.savePath = Profile::instance()->fromPortablePath(
|
||||
Path(query.value(DB_COLUMN_TARGET_SAVE_PATH.name).toString()));
|
||||
resumeData.useAutoTMM = resumeData.savePath.isEmpty();
|
||||
if (!resumeData.useAutoTMM)
|
||||
{
|
||||
resumeData.downloadPath = Profile::instance()->fromPortablePath(
|
||||
Path(query.value(DB_COLUMN_DOWNLOAD_PATH.name).toString()));
|
||||
}
|
||||
|
||||
const QByteArray bencodedResumeData = query.value(DB_COLUMN_RESUMEDATA.name).toByteArray();
|
||||
const auto *pref = Preferences::instance();
|
||||
const int bdecodeDepthLimit = pref->getBdecodeDepthLimit();
|
||||
const int bdecodeTokenLimit = pref->getBdecodeTokenLimit();
|
||||
|
||||
lt::error_code ec;
|
||||
const lt::bdecode_node resumeDataRoot = lt::bdecode(bencodedResumeData, ec
|
||||
, nullptr, bdecodeDepthLimit, bdecodeTokenLimit);
|
||||
|
||||
lt::add_torrent_params &p = resumeData.ltAddTorrentParams;
|
||||
|
||||
p = lt::read_resume_data(resumeDataRoot, ec);
|
||||
|
||||
if (const QByteArray bencodedMetadata = query.value(DB_COLUMN_METADATA.name).toByteArray()
|
||||
; !bencodedMetadata.isEmpty())
|
||||
{
|
||||
const lt::bdecode_node torentInfoRoot = lt::bdecode(bencodedMetadata, ec
|
||||
, nullptr, bdecodeDepthLimit, bdecodeTokenLimit);
|
||||
p.ti = std::make_shared<lt::torrent_info>(torentInfoRoot, ec);
|
||||
}
|
||||
|
||||
p.save_path = Profile::instance()->fromPortablePath(Path(fromLTString(p.save_path)))
|
||||
.toString().toStdString();
|
||||
|
||||
if (p.flags & lt::torrent_flags::stop_when_ready)
|
||||
{
|
||||
p.flags &= ~lt::torrent_flags::stop_when_ready;
|
||||
resumeData.stopCondition = Torrent::StopCondition::FilesChecked;
|
||||
}
|
||||
|
||||
return resumeData;
|
||||
}
|
||||
}
|
||||
|
||||
namespace BitTorrent
|
||||
|
@ -688,6 +614,90 @@ void BitTorrent::DBResumeDataStorage::enableWALMode() const
|
|||
throw RuntimeError(tr("WAL mode is probably unsupported due to filesystem limitations."));
|
||||
}
|
||||
|
||||
LoadResumeDataResult DBResumeDataStorage::parseQueryResultRow(const QSqlQuery &query) const
|
||||
{
|
||||
LoadTorrentParams resumeData;
|
||||
resumeData.name = query.value(DB_COLUMN_NAME.name).toString();
|
||||
resumeData.category = query.value(DB_COLUMN_CATEGORY.name).toString();
|
||||
const QString tagsData = query.value(DB_COLUMN_TAGS.name).toString();
|
||||
if (!tagsData.isEmpty())
|
||||
{
|
||||
const QStringList tagList = tagsData.split(u',');
|
||||
resumeData.tags.insert(tagList.cbegin(), tagList.cend());
|
||||
}
|
||||
resumeData.hasFinishedStatus = query.value(DB_COLUMN_HAS_SEED_STATUS.name).toBool();
|
||||
resumeData.firstLastPiecePriority = query.value(DB_COLUMN_HAS_OUTER_PIECES_PRIORITY.name).toBool();
|
||||
resumeData.ratioLimit = query.value(DB_COLUMN_RATIO_LIMIT.name).toInt() / 1000.0;
|
||||
resumeData.seedingTimeLimit = query.value(DB_COLUMN_SEEDING_TIME_LIMIT.name).toInt();
|
||||
resumeData.inactiveSeedingTimeLimit = query.value(DB_COLUMN_INACTIVE_SEEDING_TIME_LIMIT.name).toInt();
|
||||
resumeData.shareLimitAction = Utils::String::toEnum<ShareLimitAction>(
|
||||
query.value(DB_COLUMN_SHARE_LIMIT_ACTION.name).toString(), ShareLimitAction::Default);
|
||||
resumeData.contentLayout = Utils::String::toEnum<TorrentContentLayout>(
|
||||
query.value(DB_COLUMN_CONTENT_LAYOUT.name).toString(), TorrentContentLayout::Original);
|
||||
resumeData.operatingMode = Utils::String::toEnum<TorrentOperatingMode>(
|
||||
query.value(DB_COLUMN_OPERATING_MODE.name).toString(), TorrentOperatingMode::AutoManaged);
|
||||
resumeData.stopped = query.value(DB_COLUMN_STOPPED.name).toBool();
|
||||
resumeData.stopCondition = Utils::String::toEnum(
|
||||
query.value(DB_COLUMN_STOP_CONDITION.name).toString(), Torrent::StopCondition::None);
|
||||
resumeData.sslParameters =
|
||||
{
|
||||
.certificate = QSslCertificate(query.value(DB_COLUMN_SSL_CERTIFICATE.name).toByteArray()),
|
||||
.privateKey = Utils::SSLKey::load(query.value(DB_COLUMN_SSL_PRIVATE_KEY.name).toByteArray()),
|
||||
.dhParams = query.value(DB_COLUMN_SSL_DH_PARAMS.name).toByteArray()
|
||||
};
|
||||
|
||||
resumeData.savePath = Profile::instance()->fromPortablePath(
|
||||
Path(query.value(DB_COLUMN_TARGET_SAVE_PATH.name).toString()));
|
||||
resumeData.useAutoTMM = resumeData.savePath.isEmpty();
|
||||
if (!resumeData.useAutoTMM)
|
||||
{
|
||||
resumeData.downloadPath = Profile::instance()->fromPortablePath(
|
||||
Path(query.value(DB_COLUMN_DOWNLOAD_PATH.name).toString()));
|
||||
}
|
||||
|
||||
const QByteArray bencodedResumeData = query.value(DB_COLUMN_RESUMEDATA.name).toByteArray();
|
||||
const auto *pref = Preferences::instance();
|
||||
const int bdecodeDepthLimit = pref->getBdecodeDepthLimit();
|
||||
const int bdecodeTokenLimit = pref->getBdecodeTokenLimit();
|
||||
|
||||
lt::error_code ec;
|
||||
const lt::bdecode_node resumeDataRoot = lt::bdecode(bencodedResumeData, ec, nullptr, bdecodeDepthLimit, bdecodeTokenLimit);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse resume data: %1").arg(QString::fromStdString(ec.message())));
|
||||
|
||||
lt::add_torrent_params &p = resumeData.ltAddTorrentParams;
|
||||
|
||||
p = lt::read_resume_data(resumeDataRoot, ec);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse resume data: %1").arg(QString::fromStdString(ec.message())));
|
||||
|
||||
if (const QByteArray bencodedMetadata = query.value(DB_COLUMN_METADATA.name).toByteArray()
|
||||
; !bencodedMetadata.isEmpty())
|
||||
{
|
||||
const lt::bdecode_node torentInfoRoot = lt::bdecode(bencodedMetadata, ec
|
||||
, nullptr, bdecodeDepthLimit, bdecodeTokenLimit);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse torrent info: %1").arg(QString::fromStdString(ec.message())));
|
||||
|
||||
p.ti = std::make_shared<lt::torrent_info>(torentInfoRoot, ec);
|
||||
if (ec)
|
||||
return nonstd::make_unexpected(tr("Cannot parse torrent info: %1").arg(QString::fromStdString(ec.message())));
|
||||
}
|
||||
|
||||
p.save_path = Profile::instance()->fromPortablePath(Path(fromLTString(p.save_path)))
|
||||
.toString().toStdString();
|
||||
if (p.save_path.empty())
|
||||
return nonstd::make_unexpected(tr("Corrupted resume data: %1").arg(tr("save_path is invalid")));
|
||||
|
||||
if (p.flags & lt::torrent_flags::stop_when_ready)
|
||||
{
|
||||
p.flags &= ~lt::torrent_flags::stop_when_ready;
|
||||
resumeData.stopCondition = Torrent::StopCondition::FilesChecked;
|
||||
}
|
||||
|
||||
return resumeData;
|
||||
}
|
||||
|
||||
BitTorrent::DBResumeDataStorage::Worker::Worker(const Path &dbPath, QReadWriteLock &dbLock, QObject *parent)
|
||||
: QThread(parent)
|
||||
, m_path {dbPath}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2021-2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2021-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,9 +31,10 @@
|
|||
#include <QReadWriteLock>
|
||||
|
||||
#include "base/pathfwd.h"
|
||||
#include "base/utils/thread.h"
|
||||
#include "resumedatastorage.h"
|
||||
|
||||
class QSqlQuery;
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
class DBResumeDataStorage final : public ResumeDataStorage
|
||||
|
@ -58,6 +59,7 @@ namespace BitTorrent
|
|||
void createDB() const;
|
||||
void updateDB(int fromVersion) const;
|
||||
void enableWALMode() const;
|
||||
LoadResumeDataResult parseQueryResultRow(const QSqlQuery &query) const;
|
||||
|
||||
class Worker;
|
||||
Worker *m_asyncWorker = nullptr;
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#include "infohash.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include "base/global.h"
|
||||
|
||||
const int TorrentIDTypeId = qRegisterMetaType<BitTorrent::TorrentID>();
|
||||
|
||||
|
@ -86,6 +89,28 @@ BitTorrent::TorrentID BitTorrent::InfoHash::toTorrentID() const
|
|||
#endif
|
||||
}
|
||||
|
||||
QString BitTorrent::InfoHash::toString() const
|
||||
{
|
||||
// Returns a string that is suitable for logging purpose
|
||||
|
||||
QString ret;
|
||||
ret.reserve(40 + 64 + 2); // v1 hash length + v2 hash length + comma
|
||||
|
||||
const SHA1Hash v1Hash = v1();
|
||||
const bool v1IsValid = v1Hash.isValid();
|
||||
if (v1IsValid)
|
||||
ret += v1Hash.toString();
|
||||
|
||||
if (const SHA256Hash v2Hash = v2(); v2Hash.isValid())
|
||||
{
|
||||
if (v1IsValid)
|
||||
ret += u", ";
|
||||
ret += v2Hash.toString();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BitTorrent::InfoHash::operator WrappedType() const
|
||||
{
|
||||
return m_nativeHash;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
|
||||
#include "base/digest32.h"
|
||||
|
||||
class QString;
|
||||
|
||||
using SHA1Hash = Digest32<160>;
|
||||
using SHA256Hash = Digest32<256>;
|
||||
|
||||
|
@ -79,6 +81,8 @@ namespace BitTorrent
|
|||
SHA256Hash v2() const;
|
||||
TorrentID toTorrentID() const;
|
||||
|
||||
QString toString() const;
|
||||
|
||||
operator WrappedType() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -39,7 +39,11 @@ PeerAddress PeerAddress::parse(const QStringView address)
|
|||
if (address.startsWith(u'[') && address.contains(u"]:"))
|
||||
{ // IPv6
|
||||
ipPort = address.split(u"]:");
|
||||
ipPort[0] = ipPort[0].mid(1); // chop '['
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
ipPort[0].slice(1); // chop '['
|
||||
#else
|
||||
ipPort[0] = ipPort[0].sliced(1); // chop '['
|
||||
#endif
|
||||
}
|
||||
else if (address.contains(u':'))
|
||||
{ // IPv4
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "base/pathfwd.h"
|
||||
#include "base/tagset.h"
|
||||
#include "addtorrenterror.h"
|
||||
#include "addtorrentparams.h"
|
||||
#include "categoryoptions.h"
|
||||
#include "sharelimitaction.h"
|
||||
|
@ -237,6 +238,12 @@ namespace BitTorrent
|
|||
virtual Path finishedTorrentExportDirectory() const = 0;
|
||||
virtual void setFinishedTorrentExportDirectory(const Path &path) = 0;
|
||||
|
||||
virtual bool isAddTrackersFromURLEnabled() const = 0;
|
||||
virtual void setAddTrackersFromURLEnabled(bool enabled) = 0;
|
||||
virtual QString additionalTrackersURL() const = 0;
|
||||
virtual void setAdditionalTrackersURL(const QString &url) = 0;
|
||||
virtual QString additionalTrackersFromURL() const = 0;
|
||||
|
||||
virtual int globalDownloadSpeedLimit() const = 0;
|
||||
virtual void setGlobalDownloadSpeedLimit(int limit) = 0;
|
||||
virtual int globalUploadSpeedLimit() const = 0;
|
||||
|
@ -386,6 +393,8 @@ namespace BitTorrent
|
|||
virtual void setIncludeOverheadInLimits(bool include) = 0;
|
||||
virtual QString announceIP() const = 0;
|
||||
virtual void setAnnounceIP(const QString &ip) = 0;
|
||||
virtual int announcePort() const = 0;
|
||||
virtual void setAnnouncePort(int port) = 0;
|
||||
virtual int maxConcurrentHTTPAnnounces() const = 0;
|
||||
virtual void setMaxConcurrentHTTPAnnounces(int value) = 0;
|
||||
virtual bool isReannounceWhenAddressChangedEnabled() const = 0;
|
||||
|
@ -413,6 +422,8 @@ namespace BitTorrent
|
|||
virtual void setUTPRateLimited(bool limited) = 0;
|
||||
virtual MixedModeAlgorithm utpMixedMode() const = 0;
|
||||
virtual void setUtpMixedMode(MixedModeAlgorithm mode) = 0;
|
||||
virtual int hostnameCacheTTL() const = 0;
|
||||
virtual void setHostnameCacheTTL(int value) = 0;
|
||||
virtual bool isIDNSupportEnabled() const = 0;
|
||||
virtual void setIDNSupportEnabled(bool enabled) = 0;
|
||||
virtual bool multiConnectionsPerIpEnabled() const = 0;
|
||||
|
@ -471,9 +482,11 @@ namespace BitTorrent
|
|||
virtual QString lastExternalIPv4Address() const = 0;
|
||||
virtual QString lastExternalIPv6Address() const = 0;
|
||||
|
||||
virtual qint64 freeDiskSpace() const = 0;
|
||||
|
||||
signals:
|
||||
void startupProgressUpdated(int progress);
|
||||
void addTorrentFailed(const InfoHash &infoHash, const QString &reason);
|
||||
void addTorrentFailed(const InfoHash &infoHash, const AddTorrentError &reason);
|
||||
void allTorrentsFinished();
|
||||
void categoryAdded(const QString &categoryName);
|
||||
void categoryRemoved(const QString &categoryName);
|
||||
|
@ -511,5 +524,6 @@ namespace BitTorrent
|
|||
void trackerSuccess(Torrent *torrent, const QString &tracker);
|
||||
void trackerWarning(Torrent *torrent, const QString &tracker);
|
||||
void trackerEntryStatusesUpdated(Torrent *torrent, const QHash<QString, TrackerEntryStatus> &updatedTrackers);
|
||||
void freeDiskSpaceChecked(qint64 result);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -76,8 +76,10 @@
|
|||
#include <QUuid>
|
||||
|
||||
#include "base/algorithm.h"
|
||||
#include "base/freediskspacechecker.h"
|
||||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/net/proxyconfigurationmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/profile.h"
|
||||
|
@ -114,12 +116,13 @@ using namespace BitTorrent;
|
|||
|
||||
const Path CATEGORIES_FILE_NAME {u"categories.json"_s};
|
||||
const int MAX_PROCESSING_RESUMEDATA_COUNT = 50;
|
||||
const std::chrono::seconds FREEDISKSPACE_CHECK_TIMEOUT = 30s;
|
||||
|
||||
namespace
|
||||
{
|
||||
const char PEER_ID[] = "qB";
|
||||
const auto USER_AGENT = QStringLiteral("qBittorrent/" QBT_VERSION_2);
|
||||
const QString DEFAULT_DHT_BOOTSTRAP_NODES = u"dht.libtorrent.org:25401, dht.transmissionbt.com:6881, router.silotis.us:6881"_s;
|
||||
const QString DEFAULT_DHT_BOOTSTRAP_NODES = u"dht.libtorrent.org:25401, dht.transmissionbt.com:6881, router.bittorrent.com:6881"_s;
|
||||
|
||||
void torrentQueuePositionUp(const lt::torrent_handle &handle)
|
||||
{
|
||||
|
@ -362,7 +365,7 @@ QString Session::subcategoryName(const QString &category)
|
|||
{
|
||||
const int sepIndex = category.lastIndexOf(u'/');
|
||||
if (sepIndex >= 0)
|
||||
return category.mid(sepIndex + 1);
|
||||
return category.sliced(sepIndex + 1);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
@ -371,7 +374,7 @@ QString Session::parentCategoryName(const QString &category)
|
|||
{
|
||||
const int sepIndex = category.lastIndexOf(u'/');
|
||||
if (sepIndex >= 0)
|
||||
return category.left(sepIndex);
|
||||
return category.first(sepIndex);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -382,7 +385,7 @@ QStringList Session::expandCategory(const QString &category)
|
|||
int index = 0;
|
||||
while ((index = category.indexOf(u'/', index)) >= 0)
|
||||
{
|
||||
result << category.left(index);
|
||||
result << category.first(index);
|
||||
++index;
|
||||
}
|
||||
result << category;
|
||||
|
@ -444,6 +447,7 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
, m_ignoreLimitsOnLAN(BITTORRENT_SESSION_KEY(u"IgnoreLimitsOnLAN"_s), false)
|
||||
, m_includeOverheadInLimits(BITTORRENT_SESSION_KEY(u"IncludeOverheadInLimits"_s), false)
|
||||
, m_announceIP(BITTORRENT_SESSION_KEY(u"AnnounceIP"_s))
|
||||
, m_announcePort(BITTORRENT_SESSION_KEY(u"AnnouncePort"_s), 0)
|
||||
, m_maxConcurrentHTTPAnnounces(BITTORRENT_SESSION_KEY(u"MaxConcurrentHTTPAnnounces"_s), 50)
|
||||
, m_isReannounceWhenAddressChangedEnabled(BITTORRENT_SESSION_KEY(u"ReannounceWhenAddressChanged"_s), false)
|
||||
, m_stopTrackerTimeout(BITTORRENT_SESSION_KEY(u"StopTrackerTimeout"_s), 2)
|
||||
|
@ -456,6 +460,7 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
, m_isUTPRateLimited(BITTORRENT_SESSION_KEY(u"uTPRateLimited"_s), true)
|
||||
, m_utpMixedMode(BITTORRENT_SESSION_KEY(u"uTPMixedMode"_s), MixedModeAlgorithm::TCP
|
||||
, clampValue(MixedModeAlgorithm::TCP, MixedModeAlgorithm::Proportional))
|
||||
, m_hostnameCacheTTL(BITTORRENT_SESSION_KEY(u"HostnameCacheTTL"_s), 1200)
|
||||
, m_IDNSupportEnabled(BITTORRENT_SESSION_KEY(u"IDNSupportEnabled"_s), false)
|
||||
, m_multiConnectionsPerIpEnabled(BITTORRENT_SESSION_KEY(u"MultiConnectionsPerIp"_s), false)
|
||||
, m_validateHTTPSTrackerCertificate(BITTORRENT_SESSION_KEY(u"ValidateHTTPSTrackerCertificate"_s), true)
|
||||
|
@ -463,9 +468,13 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
, m_blockPeersOnPrivilegedPorts(BITTORRENT_SESSION_KEY(u"BlockPeersOnPrivilegedPorts"_s), false)
|
||||
, m_isAddTrackersEnabled(BITTORRENT_SESSION_KEY(u"AddTrackersEnabled"_s), false)
|
||||
, m_additionalTrackers(BITTORRENT_SESSION_KEY(u"AdditionalTrackers"_s))
|
||||
, m_isAddTrackersFromURLEnabled(BITTORRENT_SESSION_KEY(u"AddTrackersFromURLEnabled"_s), false)
|
||||
, m_additionalTrackersURL(BITTORRENT_SESSION_KEY(u"AdditionalTrackersURL"_s))
|
||||
, m_globalMaxRatio(BITTORRENT_SESSION_KEY(u"GlobalMaxRatio"_s), -1, [](qreal r) { return r < 0 ? -1. : r;})
|
||||
, m_globalMaxSeedingMinutes(BITTORRENT_SESSION_KEY(u"GlobalMaxSeedingMinutes"_s), -1, lowerLimited(-1))
|
||||
, m_globalMaxInactiveSeedingMinutes(BITTORRENT_SESSION_KEY(u"GlobalMaxInactiveSeedingMinutes"_s), -1, lowerLimited(-1))
|
||||
, m_globalMaxSeedingMinutes(BITTORRENT_SESSION_KEY(u"GlobalMaxSeedingMinutes"_s), Torrent::NO_SEEDING_TIME_LIMIT
|
||||
, clampValue(Torrent::NO_SEEDING_TIME_LIMIT, Torrent::MAX_SEEDING_TIME))
|
||||
, m_globalMaxInactiveSeedingMinutes(BITTORRENT_SESSION_KEY(u"GlobalMaxInactiveSeedingMinutes"_s), Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT
|
||||
, clampValue(Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT, Torrent::MAX_INACTIVE_SEEDING_TIME))
|
||||
, m_isAddTorrentToQueueTop(BITTORRENT_SESSION_KEY(u"AddTorrentToTopOfQueue"_s), false)
|
||||
, m_isAddTorrentStopped(BITTORRENT_SESSION_KEY(u"AddTorrentStopped"_s), false)
|
||||
, m_torrentStopCondition(BITTORRENT_SESSION_KEY(u"TorrentStopCondition"_s), Torrent::StopCondition::None)
|
||||
|
@ -536,11 +545,15 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
, m_ioThread {new QThread}
|
||||
, m_asyncWorker {new QThreadPool(this)}
|
||||
, m_recentErroredTorrentsTimer {new QTimer(this)}
|
||||
, m_freeDiskSpaceChecker {new FreeDiskSpaceChecker(savePath())}
|
||||
, m_freeDiskSpaceCheckingTimer {new QTimer(this)}
|
||||
{
|
||||
// It is required to perform async access to libtorrent sequentially
|
||||
m_asyncWorker->setMaxThreadCount(1);
|
||||
m_asyncWorker->setObjectName("SessionImpl m_asyncWorker");
|
||||
|
||||
m_alerts.reserve(1024);
|
||||
|
||||
if (port() < 0)
|
||||
m_port = Utils::Random::rand(1024, 65535);
|
||||
if (sslPort() < 0)
|
||||
|
@ -594,6 +607,18 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
, &Net::ProxyConfigurationManager::proxyConfigurationChanged
|
||||
, this, &SessionImpl::configureDeferred);
|
||||
|
||||
m_freeDiskSpaceChecker->moveToThread(m_ioThread.get());
|
||||
connect(m_ioThread.get(), &QThread::finished, m_freeDiskSpaceChecker, &QObject::deleteLater);
|
||||
m_freeDiskSpaceCheckingTimer->setInterval(FREEDISKSPACE_CHECK_TIMEOUT);
|
||||
m_freeDiskSpaceCheckingTimer->setSingleShot(true);
|
||||
connect(m_freeDiskSpaceCheckingTimer, &QTimer::timeout, m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::check);
|
||||
connect(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::checked, this, [this](const qint64 value)
|
||||
{
|
||||
m_freeDiskSpace = value;
|
||||
m_freeDiskSpaceCheckingTimer->start();
|
||||
emit freeDiskSpaceChecked(m_freeDiskSpace);
|
||||
});
|
||||
|
||||
m_fileSearcher = new FileSearcher;
|
||||
m_fileSearcher->moveToThread(m_ioThread.get());
|
||||
connect(m_ioThread.get(), &QThread::finished, m_fileSearcher, &QObject::deleteLater);
|
||||
|
@ -607,6 +632,8 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
m_ioThread->setObjectName("SessionImpl m_ioThread");
|
||||
m_ioThread->start();
|
||||
|
||||
QMetaObject::invokeMethod(m_freeDiskSpaceChecker, &FreeDiskSpaceChecker::check);
|
||||
|
||||
initMetrics();
|
||||
loadStatistics();
|
||||
|
||||
|
@ -617,6 +644,15 @@ SessionImpl::SessionImpl(QObject *parent)
|
|||
enableTracker(isTrackerEnabled());
|
||||
|
||||
prepareStartup();
|
||||
|
||||
m_updateTrackersFromURLTimer = new QTimer(this);
|
||||
m_updateTrackersFromURLTimer->setInterval(24h);
|
||||
connect(m_updateTrackersFromURLTimer, &QTimer::timeout, this, &SessionImpl::updateTrackersFromURL);
|
||||
if (isAddTrackersFromURLEnabled())
|
||||
{
|
||||
updateTrackersFromURL();
|
||||
m_updateTrackersFromURLTimer->start();
|
||||
}
|
||||
}
|
||||
|
||||
SessionImpl::~SessionImpl()
|
||||
|
@ -959,23 +995,25 @@ bool SessionImpl::editCategory(const QString &name, const CategoryOptions &optio
|
|||
if (options == currentOptions)
|
||||
return false;
|
||||
|
||||
currentOptions = options;
|
||||
storeCategories();
|
||||
if (isDisableAutoTMMWhenCategorySavePathChanged())
|
||||
{
|
||||
// This should be done before changing the category options
|
||||
// to prevent the torrent from being moved at the new save path.
|
||||
|
||||
for (TorrentImpl *const torrent : asConst(m_torrents))
|
||||
{
|
||||
if (torrent->category() == name)
|
||||
torrent->setAutoTMMEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
currentOptions = options;
|
||||
storeCategories();
|
||||
|
||||
for (TorrentImpl *const torrent : asConst(m_torrents))
|
||||
{
|
||||
for (TorrentImpl *const torrent : asConst(m_torrents))
|
||||
{
|
||||
if (torrent->category() == name)
|
||||
torrent->handleCategoryOptionsChanged();
|
||||
}
|
||||
if (torrent->category() == name)
|
||||
torrent->handleCategoryOptionsChanged();
|
||||
}
|
||||
|
||||
emit categoryOptionsChanged(name);
|
||||
|
@ -1219,8 +1257,7 @@ int SessionImpl::globalMaxSeedingMinutes() const
|
|||
|
||||
void SessionImpl::setGlobalMaxSeedingMinutes(int minutes)
|
||||
{
|
||||
if (minutes < 0)
|
||||
minutes = -1;
|
||||
minutes = std::clamp(minutes, Torrent::NO_SEEDING_TIME_LIMIT, Torrent::MAX_SEEDING_TIME);
|
||||
|
||||
if (minutes != globalMaxSeedingMinutes())
|
||||
{
|
||||
|
@ -1236,7 +1273,7 @@ int SessionImpl::globalMaxInactiveSeedingMinutes() const
|
|||
|
||||
void SessionImpl::setGlobalMaxInactiveSeedingMinutes(int minutes)
|
||||
{
|
||||
minutes = std::max(minutes, -1);
|
||||
minutes = std::clamp(minutes, Torrent::NO_INACTIVE_SEEDING_TIME_LIMIT, Torrent::MAX_INACTIVE_SEEDING_TIME);
|
||||
|
||||
if (minutes != globalMaxInactiveSeedingMinutes())
|
||||
{
|
||||
|
@ -1990,6 +2027,10 @@ lt::settings_pack SessionImpl::loadLTSettings() const
|
|||
settingsPack.set_bool(lt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits());
|
||||
// IP address to announce to trackers
|
||||
settingsPack.set_str(lt::settings_pack::announce_ip, announceIP().toStdString());
|
||||
#if LIBTORRENT_VERSION_NUM >= 20011
|
||||
// Port to announce to trackers
|
||||
settingsPack.set_int(lt::settings_pack::announce_port, announcePort());
|
||||
#endif
|
||||
// Max concurrent HTTP announces
|
||||
settingsPack.set_int(lt::settings_pack::max_concurrent_http_announces, maxConcurrentHTTPAnnounces());
|
||||
// Stop tracker timeout
|
||||
|
@ -2035,6 +2076,8 @@ lt::settings_pack SessionImpl::loadLTSettings() const
|
|||
break;
|
||||
}
|
||||
|
||||
settingsPack.set_int(lt::settings_pack::resolver_cache_timeout, hostnameCacheTTL());
|
||||
|
||||
settingsPack.set_bool(lt::settings_pack::allow_idna, isIDNSupportEnabled());
|
||||
|
||||
settingsPack.set_bool(lt::settings_pack::allow_multiple_connections_per_ip, multiConnectionsPerIpEnabled());
|
||||
|
@ -2268,6 +2311,11 @@ void SessionImpl::populateAdditionalTrackers()
|
|||
m_additionalTrackerEntries = parseTrackerEntries(additionalTrackers());
|
||||
}
|
||||
|
||||
void SessionImpl::populateAdditionalTrackersFromURL()
|
||||
{
|
||||
m_additionalTrackerEntriesFromURL = parseTrackerEntries(additionalTrackersFromURL());
|
||||
}
|
||||
|
||||
void SessionImpl::processTorrentShareLimits(TorrentImpl *torrent)
|
||||
{
|
||||
if (!torrent->isFinished() || torrent->isForced())
|
||||
|
@ -2437,12 +2485,12 @@ bool SessionImpl::removeTorrent(const TorrentID &id, const TorrentRemoveOption d
|
|||
m_removingTorrents[torrentID] = {torrentName, torrent->actualStorageLocation(), {}, deleteOption};
|
||||
|
||||
const lt::torrent_handle nativeHandle {torrent->nativeHandle()};
|
||||
const auto iter = std::find_if(m_moveStorageQueue.begin(), m_moveStorageQueue.end()
|
||||
const auto iter = std::find_if(m_moveStorageQueue.cbegin(), m_moveStorageQueue.cend()
|
||||
, [&nativeHandle](const MoveStorageJob &job)
|
||||
{
|
||||
return job.torrentHandle == nativeHandle;
|
||||
});
|
||||
if (iter != m_moveStorageQueue.end())
|
||||
if (iter != m_moveStorageQueue.cend())
|
||||
{
|
||||
// We shouldn't actually remove torrent until existing "move storage jobs" are done
|
||||
torrentQueuePositionBottom(nativeHandle);
|
||||
|
@ -2462,12 +2510,12 @@ bool SessionImpl::removeTorrent(const TorrentID &id, const TorrentRemoveOption d
|
|||
{
|
||||
// Delete "move storage job" for the deleted torrent
|
||||
// (note: we shouldn't delete active job)
|
||||
const auto iter = std::find_if((m_moveStorageQueue.begin() + 1), m_moveStorageQueue.end()
|
||||
const auto iter = std::find_if((m_moveStorageQueue.cbegin() + 1), m_moveStorageQueue.cend()
|
||||
, [torrent](const MoveStorageJob &job)
|
||||
{
|
||||
return job.torrentHandle == torrent->nativeHandle();
|
||||
});
|
||||
if (iter != m_moveStorageQueue.end())
|
||||
if (iter != m_moveStorageQueue.cend())
|
||||
m_moveStorageQueue.erase(iter);
|
||||
}
|
||||
|
||||
|
@ -2484,8 +2532,8 @@ bool SessionImpl::removeTorrent(const TorrentID &id, const TorrentRemoveOption d
|
|||
|
||||
bool SessionImpl::cancelDownloadMetadata(const TorrentID &id)
|
||||
{
|
||||
const auto downloadedMetadataIter = m_downloadedMetadata.find(id);
|
||||
if (downloadedMetadataIter == m_downloadedMetadata.end())
|
||||
const auto downloadedMetadataIter = m_downloadedMetadata.constFind(id);
|
||||
if (downloadedMetadataIter == m_downloadedMetadata.cend())
|
||||
return false;
|
||||
|
||||
const lt::torrent_handle nativeHandle = downloadedMetadataIter.value();
|
||||
|
@ -2727,7 +2775,10 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||
// We should not add the torrent if it is already
|
||||
// processed or is pending to add to session
|
||||
if (m_loadingTorrents.contains(id) || (infoHash.isHybrid() && m_loadingTorrents.contains(altID)))
|
||||
{
|
||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, tr("Duplicate torrent")});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Torrent *torrent = findTorrent(infoHash))
|
||||
{
|
||||
|
@ -2741,16 +2792,20 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||
|
||||
if (!isMergeTrackersEnabled())
|
||||
{
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: %1. Result: %2")
|
||||
.arg(torrent->name(), tr("Merging of trackers is disabled")));
|
||||
const QString message = tr("Merging of trackers is disabled");
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: \"%1\". Torrent infohash: %2. Result: %3")
|
||||
.arg(torrent->name(), torrent->infoHash().toString(), message));
|
||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool isPrivate = torrent->isPrivate() || (hasMetadata && source.info()->isPrivate());
|
||||
if (isPrivate)
|
||||
{
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: %1. Result: %2")
|
||||
.arg(torrent->name(), tr("Trackers cannot be merged because it is a private torrent")));
|
||||
const QString message = tr("Trackers cannot be merged because it is a private torrent");
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: \"%1\". Torrent infohash: %2. Result: %3")
|
||||
.arg(torrent->name(), torrent->infoHash().toString(), message));
|
||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2758,8 +2813,10 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||
torrent->addTrackers(source.trackers());
|
||||
torrent->addUrlSeeds(source.urlSeeds());
|
||||
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: %1. Result: %2")
|
||||
.arg(torrent->name(), tr("Trackers are merged from new source")));
|
||||
const QString message = tr("Trackers are merged from new source");
|
||||
LogMsg(tr("Detected an attempt to add a duplicate torrent. Existing torrent: \"%1\". Torrent infohash: %2. Result: %3")
|
||||
.arg(torrent->name(), torrent->infoHash().toString(), message));
|
||||
emit addTorrentFailed(infoHash, {AddTorrentError::DuplicateTorrent, message});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2887,6 +2944,21 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||
}
|
||||
}
|
||||
|
||||
if (isAddTrackersFromURLEnabled() && !(hasMetadata && p.ti->priv()))
|
||||
{
|
||||
const auto maxTierIter = std::max_element(p.tracker_tiers.cbegin(), p.tracker_tiers.cend());
|
||||
const int baseTier = (maxTierIter != p.tracker_tiers.cend()) ? (*maxTierIter + 1) : 0;
|
||||
|
||||
p.trackers.reserve(p.trackers.size() + static_cast<std::size_t>(m_additionalTrackerEntriesFromURL.size()));
|
||||
p.tracker_tiers.reserve(p.trackers.size() + static_cast<std::size_t>(m_additionalTrackerEntriesFromURL.size()));
|
||||
p.tracker_tiers.resize(p.trackers.size(), 0);
|
||||
for (const TrackerEntry &trackerEntry : asConst(m_additionalTrackerEntriesFromURL))
|
||||
{
|
||||
p.trackers.emplace_back(trackerEntry.url.toStdString());
|
||||
p.tracker_tiers.emplace_back(Utils::Number::clampingAdd(trackerEntry.tier, baseTier));
|
||||
}
|
||||
}
|
||||
|
||||
p.upload_limit = addTorrentParams.uploadLimit;
|
||||
p.download_limit = addTorrentParams.downloadLimit;
|
||||
|
||||
|
@ -3155,10 +3227,10 @@ void SessionImpl::saveResumeData()
|
|||
break;
|
||||
}
|
||||
|
||||
const std::vector<lt::alert *> alerts = getPendingAlerts(waitTime);
|
||||
fetchPendingAlerts(waitTime);
|
||||
|
||||
bool hasWantedAlert = false;
|
||||
for (const lt::alert *alert : alerts)
|
||||
for (const lt::alert *alert : m_alerts)
|
||||
{
|
||||
if (const int alertType = alert->type();
|
||||
(alertType == lt::save_resume_data_alert::alert_type) || (alertType == lt::save_resume_data_failed_alert::alert_type)
|
||||
|
@ -3208,6 +3280,9 @@ void SessionImpl::setSavePath(const Path &path)
|
|||
|
||||
if (isDisableAutoTMMWhenDefaultSavePathChanged())
|
||||
{
|
||||
// This should be done before changing the save path
|
||||
// to prevent the torrent from being moved at the new save path.
|
||||
|
||||
QSet<QString> affectedCatogories {{}}; // includes default (unnamed) category
|
||||
for (auto it = m_categories.cbegin(); it != m_categories.cend(); ++it)
|
||||
{
|
||||
|
@ -3227,6 +3302,14 @@ void SessionImpl::setSavePath(const Path &path)
|
|||
m_savePath = newPath;
|
||||
for (TorrentImpl *const torrent : asConst(m_torrents))
|
||||
torrent->handleCategoryOptionsChanged();
|
||||
|
||||
m_freeDiskSpace = -1;
|
||||
m_freeDiskSpaceCheckingTimer->stop();
|
||||
QMetaObject::invokeMethod(m_freeDiskSpaceChecker, [checker = m_freeDiskSpaceChecker, pathToCheck = m_savePath]
|
||||
{
|
||||
checker->setPathToCheck(pathToCheck);
|
||||
checker->check();
|
||||
});
|
||||
}
|
||||
|
||||
void SessionImpl::setDownloadPath(const Path &path)
|
||||
|
@ -3237,6 +3320,9 @@ void SessionImpl::setDownloadPath(const Path &path)
|
|||
|
||||
if (isDisableAutoTMMWhenDefaultSavePathChanged())
|
||||
{
|
||||
// This should be done before changing the save path
|
||||
// to prevent the torrent from being moved at the new save path.
|
||||
|
||||
QSet<QString> affectedCatogories {{}}; // includes default (unnamed) category
|
||||
for (auto it = m_categories.cbegin(); it != m_categories.cend(); ++it)
|
||||
{
|
||||
|
@ -3879,6 +3965,82 @@ void SessionImpl::setAdditionalTrackers(const QString &trackers)
|
|||
populateAdditionalTrackers();
|
||||
}
|
||||
|
||||
bool SessionImpl::isAddTrackersFromURLEnabled() const
|
||||
{
|
||||
return m_isAddTrackersFromURLEnabled;
|
||||
}
|
||||
|
||||
void SessionImpl::setAddTrackersFromURLEnabled(const bool enabled)
|
||||
{
|
||||
if (enabled != isAddTrackersFromURLEnabled())
|
||||
{
|
||||
m_isAddTrackersFromURLEnabled = enabled;
|
||||
if (enabled)
|
||||
{
|
||||
updateTrackersFromURL();
|
||||
m_updateTrackersFromURLTimer->start();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_updateTrackersFromURLTimer->stop();
|
||||
setAdditionalTrackersFromURL({});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString SessionImpl::additionalTrackersURL() const
|
||||
{
|
||||
return m_additionalTrackersURL;
|
||||
}
|
||||
|
||||
void SessionImpl::setAdditionalTrackersURL(const QString &url)
|
||||
{
|
||||
if (url != additionalTrackersURL())
|
||||
{
|
||||
m_additionalTrackersURL = url.trimmed();
|
||||
if (isAddTrackersFromURLEnabled())
|
||||
updateTrackersFromURL();
|
||||
}
|
||||
}
|
||||
|
||||
QString SessionImpl::additionalTrackersFromURL() const
|
||||
{
|
||||
return m_additionalTrackersFromURL;
|
||||
}
|
||||
|
||||
void SessionImpl::setAdditionalTrackersFromURL(const QString &trackers)
|
||||
{
|
||||
if (trackers != additionalTrackersFromURL())
|
||||
{
|
||||
m_additionalTrackersFromURL = trackers;
|
||||
populateAdditionalTrackersFromURL();
|
||||
}
|
||||
}
|
||||
|
||||
void SessionImpl::updateTrackersFromURL()
|
||||
{
|
||||
const QString url = additionalTrackersURL();
|
||||
if (url.isEmpty())
|
||||
{
|
||||
setAdditionalTrackersFromURL({});
|
||||
}
|
||||
else
|
||||
{
|
||||
Net::DownloadManager::instance()->download(Net::DownloadRequest(url)
|
||||
, Preferences::instance()->useProxyForGeneralPurposes(), this, [this](const Net::DownloadResult &result)
|
||||
{
|
||||
if (result.status == Net::DownloadStatus::Success)
|
||||
{
|
||||
setAdditionalTrackersFromURL(QString::fromUtf8(result.data));
|
||||
LogMsg(tr("Tracker list updated"), Log::INFO);
|
||||
return;
|
||||
}
|
||||
|
||||
LogMsg(tr("Failed to update tracker list. Reason: \"%1\"").arg(result.errorString), Log::WARNING);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool SessionImpl::isIPFilteringEnabled() const
|
||||
{
|
||||
return m_isIPFilteringEnabled;
|
||||
|
@ -4769,6 +4931,20 @@ void SessionImpl::setAnnounceIP(const QString &ip)
|
|||
}
|
||||
}
|
||||
|
||||
int SessionImpl::announcePort() const
|
||||
{
|
||||
return m_announcePort;
|
||||
}
|
||||
|
||||
void SessionImpl::setAnnouncePort(const int port)
|
||||
{
|
||||
if (port != m_announcePort)
|
||||
{
|
||||
m_announcePort = port;
|
||||
configureDeferred();
|
||||
}
|
||||
}
|
||||
|
||||
int SessionImpl::maxConcurrentHTTPAnnounces() const
|
||||
{
|
||||
return m_maxConcurrentHTTPAnnounces;
|
||||
|
@ -4895,6 +5071,20 @@ void SessionImpl::setUtpMixedMode(const MixedModeAlgorithm mode)
|
|||
configureDeferred();
|
||||
}
|
||||
|
||||
int SessionImpl::hostnameCacheTTL() const
|
||||
{
|
||||
return m_hostnameCacheTTL;
|
||||
}
|
||||
|
||||
void SessionImpl::setHostnameCacheTTL(const int value)
|
||||
{
|
||||
if (value == hostnameCacheTTL())
|
||||
return;
|
||||
|
||||
m_hostnameCacheTTL = value;
|
||||
configureDeferred();
|
||||
}
|
||||
|
||||
bool SessionImpl::isIDNSupportEnabled() const
|
||||
{
|
||||
return m_IDNSupportEnabled;
|
||||
|
@ -4984,6 +5174,11 @@ QString SessionImpl::lastExternalIPv6Address() const
|
|||
return m_lastExternalIPv6Address;
|
||||
}
|
||||
|
||||
qint64 SessionImpl::freeDiskSpace() const
|
||||
{
|
||||
return m_freeDiskSpace;
|
||||
}
|
||||
|
||||
bool SessionImpl::isListening() const
|
||||
{
|
||||
return m_nativeSessionExtension->isSessionListening();
|
||||
|
@ -5139,8 +5334,8 @@ void SessionImpl::handleTorrentFinished(TorrentImpl *const torrent)
|
|||
void SessionImpl::handleTorrentResumeDataReady(TorrentImpl *const torrent, const LoadTorrentParams &data)
|
||||
{
|
||||
m_resumeDataStorage->store(torrent->id(), data);
|
||||
const auto iter = m_changedTorrentIDs.find(torrent->id());
|
||||
if (iter != m_changedTorrentIDs.end())
|
||||
const auto iter = m_changedTorrentIDs.constFind(torrent->id());
|
||||
if (iter != m_changedTorrentIDs.cend())
|
||||
{
|
||||
m_resumeDataStorage->remove(iter.value());
|
||||
m_changedTorrentIDs.erase(iter);
|
||||
|
@ -5173,11 +5368,11 @@ bool SessionImpl::addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &new
|
|||
|
||||
const lt::torrent_handle torrentHandle = torrent->nativeHandle();
|
||||
const Path currentLocation = torrent->actualStorageLocation();
|
||||
const bool torrentHasActiveJob = !m_moveStorageQueue.isEmpty() && (m_moveStorageQueue.first().torrentHandle == torrentHandle);
|
||||
const bool torrentHasActiveJob = !m_moveStorageQueue.isEmpty() && (m_moveStorageQueue.constFirst().torrentHandle == torrentHandle);
|
||||
|
||||
if (m_moveStorageQueue.size() > 1)
|
||||
{
|
||||
auto iter = std::find_if((m_moveStorageQueue.begin() + 1), m_moveStorageQueue.end()
|
||||
auto iter = std::find_if((m_moveStorageQueue.cbegin() + 1), m_moveStorageQueue.cend()
|
||||
, [&torrentHandle](const MoveStorageJob &job)
|
||||
{
|
||||
return job.torrentHandle == torrentHandle;
|
||||
|
@ -5196,7 +5391,7 @@ bool SessionImpl::addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &new
|
|||
{
|
||||
// if there is active job for this torrent prevent creating meaningless
|
||||
// job that will move torrent to the same location as current one
|
||||
if (m_moveStorageQueue.first().path == newPath)
|
||||
if (m_moveStorageQueue.constFirst().path == newPath)
|
||||
{
|
||||
LogMsg(tr("Failed to enqueue torrent move. Torrent: \"%1\". Source: \"%2\". Destination: \"%3\". Reason: torrent is currently moving to the destination")
|
||||
.arg(torrent->name(), currentLocation.toString(), newPath.toString()));
|
||||
|
@ -5241,7 +5436,7 @@ void SessionImpl::handleMoveTorrentStorageJobFinished(const Path &newPath)
|
|||
{
|
||||
const MoveStorageJob finishedJob = m_moveStorageQueue.takeFirst();
|
||||
if (!m_moveStorageQueue.isEmpty())
|
||||
moveTorrentStorage(m_moveStorageQueue.first());
|
||||
moveTorrentStorage(m_moveStorageQueue.constFirst());
|
||||
|
||||
const auto iter = std::find_if(m_moveStorageQueue.cbegin(), m_moveStorageQueue.cend()
|
||||
, [&finishedJob](const MoveStorageJob &job)
|
||||
|
@ -5495,14 +5690,13 @@ void SessionImpl::handleIPFilterError()
|
|||
emit IPFilterParsed(true, 0);
|
||||
}
|
||||
|
||||
std::vector<lt::alert *> SessionImpl::getPendingAlerts(const lt::time_duration time) const
|
||||
void SessionImpl::fetchPendingAlerts(const lt::time_duration time)
|
||||
{
|
||||
if (time > lt::time_duration::zero())
|
||||
m_nativeSession->wait_for_alert(time);
|
||||
|
||||
std::vector<lt::alert *> alerts;
|
||||
m_nativeSession->pop_alerts(&alerts);
|
||||
return alerts;
|
||||
m_alerts.clear();
|
||||
m_nativeSession->pop_alerts(&m_alerts);
|
||||
}
|
||||
|
||||
TorrentContentLayout SessionImpl::torrentContentLayout() const
|
||||
|
@ -5518,7 +5712,7 @@ void SessionImpl::setTorrentContentLayout(const TorrentContentLayout value)
|
|||
// Read alerts sent by libtorrent session
|
||||
void SessionImpl::readAlerts()
|
||||
{
|
||||
const std::vector<lt::alert *> alerts = getPendingAlerts();
|
||||
fetchPendingAlerts();
|
||||
|
||||
Q_ASSERT(m_loadedTorrents.isEmpty());
|
||||
Q_ASSERT(m_receivedAddTorrentAlertsCount == 0);
|
||||
|
@ -5526,7 +5720,7 @@ void SessionImpl::readAlerts()
|
|||
if (!isRestored())
|
||||
m_loadedTorrents.reserve(MAX_PROCESSING_RESUMEDATA_COUNT);
|
||||
|
||||
for (const lt::alert *a : alerts)
|
||||
for (const lt::alert *a : m_alerts)
|
||||
handleAlert(a);
|
||||
|
||||
if (m_receivedAddTorrentAlertsCount > 0)
|
||||
|
@ -5568,14 +5762,16 @@ void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
|||
#else
|
||||
const InfoHash infoHash {(hasMetadata ? params.ti->info_hash() : params.info_hash)};
|
||||
#endif
|
||||
if (const auto loadingTorrentsIter = m_loadingTorrents.find(TorrentID::fromInfoHash(infoHash))
|
||||
; loadingTorrentsIter != m_loadingTorrents.end())
|
||||
if (const auto loadingTorrentsIter = m_loadingTorrents.constFind(TorrentID::fromInfoHash(infoHash))
|
||||
; loadingTorrentsIter != m_loadingTorrents.cend())
|
||||
{
|
||||
emit addTorrentFailed(infoHash, msg);
|
||||
const AddTorrentError::Kind errorKind = (alert->error == lt::errors::duplicate_torrent)
|
||||
? AddTorrentError::DuplicateTorrent : AddTorrentError::Other;
|
||||
emit addTorrentFailed(infoHash, {errorKind, msg});
|
||||
m_loadingTorrents.erase(loadingTorrentsIter);
|
||||
}
|
||||
else if (const auto downloadedMetadataIter = m_downloadedMetadata.find(TorrentID::fromInfoHash(infoHash))
|
||||
; downloadedMetadataIter != m_downloadedMetadata.end())
|
||||
else if (const auto downloadedMetadataIter = m_downloadedMetadata.constFind(TorrentID::fromInfoHash(infoHash))
|
||||
; downloadedMetadataIter != m_downloadedMetadata.cend())
|
||||
{
|
||||
m_downloadedMetadata.erase(downloadedMetadataIter);
|
||||
if (infoHash.isHybrid())
|
||||
|
@ -5596,8 +5792,8 @@ void SessionImpl::handleAddTorrentAlert(const lt::add_torrent_alert *alert)
|
|||
#endif
|
||||
const auto torrentID = TorrentID::fromInfoHash(infoHash);
|
||||
|
||||
if (const auto loadingTorrentsIter = m_loadingTorrents.find(torrentID)
|
||||
; loadingTorrentsIter != m_loadingTorrents.end())
|
||||
if (const auto loadingTorrentsIter = m_loadingTorrents.constFind(torrentID)
|
||||
; loadingTorrentsIter != m_loadingTorrents.cend())
|
||||
{
|
||||
const LoadTorrentParams params = loadingTorrentsIter.value();
|
||||
m_loadingTorrents.erase(loadingTorrentsIter);
|
||||
|
@ -5860,7 +6056,7 @@ void SessionImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert
|
|||
const TorrentID torrentID {alert->handle.info_hash()};
|
||||
|
||||
bool found = false;
|
||||
if (const auto iter = m_downloadedMetadata.find(torrentID); iter != m_downloadedMetadata.end())
|
||||
if (const auto iter = m_downloadedMetadata.constFind(torrentID); iter != m_downloadedMetadata.cend())
|
||||
{
|
||||
found = true;
|
||||
m_downloadedMetadata.erase(iter);
|
||||
|
@ -5870,7 +6066,7 @@ void SessionImpl::handleMetadataReceivedAlert(const lt::metadata_received_alert
|
|||
if (infoHash.isHybrid())
|
||||
{
|
||||
const auto altID = TorrentID::fromSHA1Hash(infoHash.v1());
|
||||
if (const auto iter = m_downloadedMetadata.find(altID); iter != m_downloadedMetadata.end())
|
||||
if (const auto iter = m_downloadedMetadata.constFind(altID); iter != m_downloadedMetadata.cend())
|
||||
{
|
||||
found = true;
|
||||
m_downloadedMetadata.erase(iter);
|
||||
|
@ -5965,7 +6161,7 @@ void SessionImpl::handleUrlSeedAlert(const lt::url_seed_alert *alert)
|
|||
|
||||
if (alert->error)
|
||||
{
|
||||
LogMsg(tr("URL seed DNS lookup failed. Torrent: \"%1\". URL: \"%2\". Error: \"%3\"")
|
||||
LogMsg(tr("URL seed connection failed. Torrent: \"%1\". URL: \"%2\". Error: \"%3\"")
|
||||
.arg(torrent->name(), QString::fromUtf8(alert->server_url()), QString::fromStdString(alert->message()))
|
||||
, Log::WARNING);
|
||||
}
|
||||
|
@ -6132,7 +6328,7 @@ void SessionImpl::handleStorageMovedAlert(const lt::storage_moved_alert *alert)
|
|||
{
|
||||
Q_ASSERT(!m_moveStorageQueue.isEmpty());
|
||||
|
||||
const MoveStorageJob ¤tJob = m_moveStorageQueue.first();
|
||||
const MoveStorageJob ¤tJob = m_moveStorageQueue.constFirst();
|
||||
Q_ASSERT(currentJob.torrentHandle == alert->handle);
|
||||
|
||||
const Path newPath {QString::fromUtf8(alert->storage_path())};
|
||||
|
@ -6155,7 +6351,7 @@ void SessionImpl::handleStorageMovedFailedAlert(const lt::storage_moved_failed_a
|
|||
{
|
||||
Q_ASSERT(!m_moveStorageQueue.isEmpty());
|
||||
|
||||
const MoveStorageJob ¤tJob = m_moveStorageQueue.first();
|
||||
const MoveStorageJob ¤tJob = m_moveStorageQueue.constFirst();
|
||||
Q_ASSERT(currentJob.torrentHandle == alert->handle);
|
||||
|
||||
#ifdef QBT_USES_LIBTORRENT2
|
||||
|
@ -6328,7 +6524,7 @@ void SessionImpl::loadStatistics()
|
|||
|
||||
void SessionImpl::updateTrackerEntryStatuses(lt::torrent_handle torrentHandle)
|
||||
{
|
||||
invokeAsync([this, torrentHandle = std::move(torrentHandle)]() mutable
|
||||
invokeAsync([this, torrentHandle = std::move(torrentHandle)]
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -6338,9 +6534,9 @@ void SessionImpl::updateTrackerEntryStatuses(lt::torrent_handle torrentHandle)
|
|||
QHash<std::string, QHash<lt::tcp::endpoint, QMap<int, int>>> updatedTrackers = m_updatedTrackerStatuses.take(torrentHandle);
|
||||
updatedTrackerStatusesLocker.unlock();
|
||||
|
||||
invoke([this, torrentHandle, nativeTrackers = std::move(nativeTrackers), updatedTrackers = std::move(updatedTrackers)]
|
||||
invoke([this, infoHash = torrentHandle.info_hash(), nativeTrackers = std::move(nativeTrackers), updatedTrackers = std::move(updatedTrackers)]
|
||||
{
|
||||
TorrentImpl *torrent = m_torrents.value(torrentHandle.info_hash());
|
||||
TorrentImpl *torrent = m_torrents.value(infoHash);
|
||||
if (!torrent || torrent->isStopped())
|
||||
return;
|
||||
|
||||
|
@ -6369,8 +6565,8 @@ void SessionImpl::updateTrackerEntryStatuses(lt::torrent_handle torrentHandle)
|
|||
|
||||
void SessionImpl::handleRemovedTorrent(const TorrentID &torrentID, const QString &partfileRemoveError)
|
||||
{
|
||||
const auto removingTorrentDataIter = m_removingTorrents.find(torrentID);
|
||||
if (removingTorrentDataIter == m_removingTorrents.end())
|
||||
const auto removingTorrentDataIter = m_removingTorrents.constFind(torrentID);
|
||||
if (removingTorrentDataIter == m_removingTorrents.cend())
|
||||
return;
|
||||
|
||||
if (!partfileRemoveError.isEmpty())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -64,6 +64,7 @@ class QUrl;
|
|||
class BandwidthScheduler;
|
||||
class FileSearcher;
|
||||
class FilterParserThread;
|
||||
class FreeDiskSpaceChecker;
|
||||
class NativeSessionExtension;
|
||||
|
||||
namespace BitTorrent
|
||||
|
@ -361,6 +362,8 @@ namespace BitTorrent
|
|||
void setIncludeOverheadInLimits(bool include) override;
|
||||
QString announceIP() const override;
|
||||
void setAnnounceIP(const QString &ip) override;
|
||||
int announcePort() const override;
|
||||
void setAnnouncePort(int port) override;
|
||||
int maxConcurrentHTTPAnnounces() const override;
|
||||
void setMaxConcurrentHTTPAnnounces(int value) override;
|
||||
bool isReannounceWhenAddressChangedEnabled() const override;
|
||||
|
@ -388,6 +391,8 @@ namespace BitTorrent
|
|||
void setUTPRateLimited(bool limited) override;
|
||||
MixedModeAlgorithm utpMixedMode() const override;
|
||||
void setUtpMixedMode(MixedModeAlgorithm mode) override;
|
||||
int hostnameCacheTTL() const override;
|
||||
void setHostnameCacheTTL(int value) override;
|
||||
bool isIDNSupportEnabled() const override;
|
||||
void setIDNSupportEnabled(bool enabled) override;
|
||||
bool multiConnectionsPerIpEnabled() const override;
|
||||
|
@ -446,6 +451,8 @@ namespace BitTorrent
|
|||
QString lastExternalIPv4Address() const override;
|
||||
QString lastExternalIPv6Address() const override;
|
||||
|
||||
qint64 freeDiskSpace() const override;
|
||||
|
||||
// Torrent interface
|
||||
void handleTorrentResumeDataRequested(const TorrentImpl *torrent);
|
||||
void handleTorrentShareLimitChanged(TorrentImpl *torrent);
|
||||
|
@ -491,6 +498,12 @@ namespace BitTorrent
|
|||
m_asyncWorker->start(std::forward<Func>(func));
|
||||
}
|
||||
|
||||
bool isAddTrackersFromURLEnabled() const override;
|
||||
void setAddTrackersFromURLEnabled(bool enabled) override;
|
||||
QString additionalTrackersURL() const override;
|
||||
void setAdditionalTrackersURL(const QString &url) override;
|
||||
QString additionalTrackersFromURL() const override;
|
||||
|
||||
signals:
|
||||
void addTorrentAlertsReceived(qsizetype count);
|
||||
|
||||
|
@ -596,7 +609,9 @@ namespace BitTorrent
|
|||
void saveTorrentsQueue();
|
||||
void removeTorrentsQueue();
|
||||
|
||||
std::vector<lt::alert *> getPendingAlerts(lt::time_duration time = lt::time_duration::zero()) const;
|
||||
void populateAdditionalTrackersFromURL();
|
||||
|
||||
void fetchPendingAlerts(lt::time_duration time = lt::time_duration::zero());
|
||||
|
||||
void moveTorrentStorage(const MoveStorageJob &job) const;
|
||||
void handleMoveTorrentStorageJobFinished(const Path &newPath);
|
||||
|
@ -614,6 +629,9 @@ namespace BitTorrent
|
|||
|
||||
void handleRemovedTorrent(const TorrentID &torrentID, const QString &partfileRemoveError = {});
|
||||
|
||||
void setAdditionalTrackersFromURL(const QString &trackers);
|
||||
void updateTrackersFromURL();
|
||||
|
||||
CachedSettingValue<QString> m_DHTBootstrapNodes;
|
||||
CachedSettingValue<bool> m_isDHTEnabled;
|
||||
CachedSettingValue<bool> m_isLSDEnabled;
|
||||
|
@ -659,6 +677,7 @@ namespace BitTorrent
|
|||
CachedSettingValue<bool> m_ignoreLimitsOnLAN;
|
||||
CachedSettingValue<bool> m_includeOverheadInLimits;
|
||||
CachedSettingValue<QString> m_announceIP;
|
||||
CachedSettingValue<int> m_announcePort;
|
||||
CachedSettingValue<int> m_maxConcurrentHTTPAnnounces;
|
||||
CachedSettingValue<bool> m_isReannounceWhenAddressChangedEnabled;
|
||||
CachedSettingValue<int> m_stopTrackerTimeout;
|
||||
|
@ -669,6 +688,7 @@ namespace BitTorrent
|
|||
CachedSettingValue<BTProtocol> m_btProtocol;
|
||||
CachedSettingValue<bool> m_isUTPRateLimited;
|
||||
CachedSettingValue<MixedModeAlgorithm> m_utpMixedMode;
|
||||
CachedSettingValue<int> m_hostnameCacheTTL;
|
||||
CachedSettingValue<bool> m_IDNSupportEnabled;
|
||||
CachedSettingValue<bool> m_multiConnectionsPerIpEnabled;
|
||||
CachedSettingValue<bool> m_validateHTTPSTrackerCertificate;
|
||||
|
@ -676,6 +696,8 @@ namespace BitTorrent
|
|||
CachedSettingValue<bool> m_blockPeersOnPrivilegedPorts;
|
||||
CachedSettingValue<bool> m_isAddTrackersEnabled;
|
||||
CachedSettingValue<QString> m_additionalTrackers;
|
||||
CachedSettingValue<bool> m_isAddTrackersFromURLEnabled;
|
||||
CachedSettingValue<QString> m_additionalTrackersURL;
|
||||
CachedSettingValue<qreal> m_globalMaxRatio;
|
||||
CachedSettingValue<int> m_globalMaxSeedingMinutes;
|
||||
CachedSettingValue<int> m_globalMaxInactiveSeedingMinutes;
|
||||
|
@ -749,6 +771,9 @@ namespace BitTorrent
|
|||
bool m_IPFilteringConfigured = false;
|
||||
mutable bool m_listenInterfaceConfigured = false;
|
||||
|
||||
QString m_additionalTrackersFromURL;
|
||||
QTimer *m_updateTrackersFromURLTimer = nullptr;
|
||||
|
||||
bool m_isRestored = false;
|
||||
bool m_isPaused = isStartPaused();
|
||||
|
||||
|
@ -759,6 +784,7 @@ namespace BitTorrent
|
|||
|
||||
int m_numResumeData = 0;
|
||||
QList<TrackerEntry> m_additionalTrackerEntries;
|
||||
QList<TrackerEntry> m_additionalTrackerEntriesFromURL;
|
||||
QList<QRegularExpression> m_excludedFileNamesRegExpList;
|
||||
|
||||
// Statistics
|
||||
|
@ -794,6 +820,7 @@ namespace BitTorrent
|
|||
QMap<QString, CategoryOptions> m_categories;
|
||||
TagSet m_tags;
|
||||
|
||||
std::vector<lt::alert *> m_alerts; // make it a class variable so it can preserve its allocated `capacity`
|
||||
qsizetype m_receivedAddTorrentAlertsCount = 0;
|
||||
QList<Torrent *> m_loadedTorrents;
|
||||
|
||||
|
@ -829,6 +856,10 @@ namespace BitTorrent
|
|||
|
||||
QList<TorrentImpl *> m_pendingFinishedTorrents;
|
||||
|
||||
FreeDiskSpaceChecker *m_freeDiskSpaceChecker = nullptr;
|
||||
QTimer *m_freeDiskSpaceCheckingTimer = nullptr;
|
||||
qint64 m_freeDiskSpace = -1;
|
||||
|
||||
friend void Session::initInstance();
|
||||
friend void Session::freeInstance();
|
||||
friend Session *Session::instance();
|
||||
|
|
|
@ -463,7 +463,13 @@ qlonglong TorrentImpl::wastedSize() const
|
|||
|
||||
QString TorrentImpl::currentTracker() const
|
||||
{
|
||||
return QString::fromStdString(m_nativeStatus.current_tracker);
|
||||
if (!m_nativeStatus.current_tracker.empty())
|
||||
return QString::fromStdString(m_nativeStatus.current_tracker);
|
||||
|
||||
if (!m_trackerEntryStatuses.isEmpty())
|
||||
return m_trackerEntryStatuses.constFirst().url;
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Path TorrentImpl::savePath() const
|
||||
|
@ -1609,18 +1615,20 @@ bool TorrentImpl::setCategory(const QString &category)
|
|||
if (!category.isEmpty() && !m_session->categories().contains(category))
|
||||
return false;
|
||||
|
||||
if (m_session->isDisableAutoTMMWhenCategoryChanged())
|
||||
{
|
||||
// This should be done before changing the category name
|
||||
// to prevent the torrent from being moved at the path of new category.
|
||||
setAutoTMMEnabled(false);
|
||||
}
|
||||
|
||||
const QString oldCategory = m_category;
|
||||
m_category = category;
|
||||
deferredRequestResumeData();
|
||||
m_session->handleTorrentCategoryChanged(this, oldCategory);
|
||||
|
||||
if (m_useAutoTMM)
|
||||
{
|
||||
if (!m_session->isDisableAutoTMMWhenCategoryChanged())
|
||||
adjustStorageLocation();
|
||||
else
|
||||
setAutoTMMEnabled(false);
|
||||
}
|
||||
adjustStorageLocation();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -2845,38 +2853,26 @@ QString TorrentImpl::createMagnetURI() const
|
|||
|
||||
const SHA1Hash infoHash1 = infoHash().v1();
|
||||
if (infoHash1.isValid())
|
||||
{
|
||||
ret += u"xt=urn:btih:" + infoHash1.toString();
|
||||
}
|
||||
|
||||
const SHA256Hash infoHash2 = infoHash().v2();
|
||||
if (infoHash2.isValid())
|
||||
if (const SHA256Hash infoHash2 = infoHash().v2(); infoHash2.isValid())
|
||||
{
|
||||
if (infoHash1.isValid())
|
||||
ret += u'&';
|
||||
ret += u"xt=urn:btmh:1220" + infoHash2.toString();
|
||||
}
|
||||
|
||||
const QString displayName = name();
|
||||
if (displayName != id().toString())
|
||||
{
|
||||
if (const QString displayName = name(); displayName != id().toString())
|
||||
ret += u"&dn=" + QString::fromLatin1(QUrl::toPercentEncoding(displayName));
|
||||
}
|
||||
|
||||
if (hasMetadata())
|
||||
{
|
||||
ret += u"&xl=" + QString::number(totalSize());
|
||||
}
|
||||
|
||||
for (const TrackerEntryStatus &tracker : asConst(trackers()))
|
||||
{
|
||||
ret += u"&tr=" + QString::fromLatin1(QUrl::toPercentEncoding(tracker.url));
|
||||
}
|
||||
|
||||
for (const QUrl &urlSeed : asConst(urlSeeds()))
|
||||
{
|
||||
ret += u"&ws=" + QString::fromLatin1(urlSeed.toEncoded());
|
||||
}
|
||||
ret += u"&ws=" + urlSeed.toString(QUrl::FullyEncoded);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ void Tracker::registerPeer(const TrackerAnnounceRequest &announceReq)
|
|||
{
|
||||
// Reached max size, remove a random torrent
|
||||
if (m_torrents.size() >= MAX_TORRENTS)
|
||||
m_torrents.erase(m_torrents.begin());
|
||||
m_torrents.erase(m_torrents.cbegin());
|
||||
}
|
||||
|
||||
m_torrents[announceReq.torrentID].setPeer(announceReq.peer);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2023-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2018 Thomas Piccirello <thomas.piccirello@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -29,16 +29,24 @@
|
|||
|
||||
#include "freediskspacechecker.h"
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/utils/fs.h"
|
||||
|
||||
qint64 FreeDiskSpaceChecker::lastResult() const
|
||||
FreeDiskSpaceChecker::FreeDiskSpaceChecker(const Path &pathToCheck)
|
||||
: m_pathToCheck {pathToCheck}
|
||||
{
|
||||
return m_lastResult;
|
||||
}
|
||||
|
||||
Path FreeDiskSpaceChecker::pathToCheck() const
|
||||
{
|
||||
return m_pathToCheck;
|
||||
}
|
||||
|
||||
void FreeDiskSpaceChecker::setPathToCheck(const Path &newPathToCheck)
|
||||
{
|
||||
m_pathToCheck = newPathToCheck;
|
||||
}
|
||||
|
||||
void FreeDiskSpaceChecker::check()
|
||||
{
|
||||
m_lastResult = Utils::Fs::freeDiskSpaceOnPath(BitTorrent::Session::instance()->savePath());
|
||||
emit checked(m_lastResult);
|
||||
emit checked(Utils::Fs::freeDiskSpaceOnPath(m_pathToCheck));
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2023 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2023-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2018 Thomas Piccirello <thomas.piccirello@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -31,15 +31,18 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include "base/path.h"
|
||||
|
||||
class FreeDiskSpaceChecker final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(FreeDiskSpaceChecker)
|
||||
|
||||
public:
|
||||
using QObject::QObject;
|
||||
FreeDiskSpaceChecker(const Path &pathToCheck);
|
||||
|
||||
qint64 lastResult() const;
|
||||
Path pathToCheck() const;
|
||||
void setPathToCheck(const Path &newPathToCheck);
|
||||
|
||||
public slots:
|
||||
void check();
|
||||
|
@ -48,5 +51,5 @@ signals:
|
|||
void checked(qint64 freeSpaceSize);
|
||||
|
||||
private:
|
||||
qint64 m_lastResult = 0;
|
||||
Path m_pathToCheck;
|
||||
};
|
|
@ -155,7 +155,11 @@ void Connection::read()
|
|||
sendResponse(resp);
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
m_receivedData.slice(result.frameSize);
|
||||
#else
|
||||
m_receivedData.remove(0, result.frameSize);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ namespace
|
|||
return false;
|
||||
}
|
||||
|
||||
const QString name = line.left(i).trimmed().toString().toLower();
|
||||
const QString value = line.mid(i + 1).trimmed().toString();
|
||||
const QString name = line.first(i).trimmed().toString().toLower();
|
||||
const QString value = line.sliced(i + 1).trimmed().toString();
|
||||
out[name] = value;
|
||||
|
||||
return true;
|
||||
|
@ -164,7 +164,7 @@ bool RequestParser::parseStartLines(const QStringView data)
|
|||
if (line.at(0).isSpace() && !requestLines.isEmpty())
|
||||
{
|
||||
// continuation of previous line
|
||||
requestLines.last() += line.toString();
|
||||
requestLines.last() += line;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -204,15 +204,15 @@ bool RequestParser::parseRequestLine(const QString &line)
|
|||
m_request.method = match.captured(1);
|
||||
|
||||
// Request Target
|
||||
const QByteArray url {match.captured(2).toLatin1()};
|
||||
const QByteArray url {match.capturedView(2).toLatin1()};
|
||||
const int sepPos = url.indexOf('?');
|
||||
const QByteArrayView pathComponent = ((sepPos == -1) ? url : QByteArrayView(url).mid(0, sepPos));
|
||||
const QByteArrayView pathComponent = ((sepPos == -1) ? url : QByteArrayView(url).first(sepPos));
|
||||
|
||||
m_request.path = QString::fromUtf8(QByteArray::fromPercentEncoding(asQByteArray(pathComponent)));
|
||||
|
||||
if (sepPos >= 0)
|
||||
{
|
||||
const QByteArrayView query = QByteArrayView(url).mid(sepPos + 1);
|
||||
const QByteArrayView query = QByteArrayView(url).sliced(sepPos + 1);
|
||||
|
||||
// [rfc3986] 2.4 When to Encode or Decode
|
||||
// URL components should be separated before percent-decoding
|
||||
|
@ -221,13 +221,11 @@ bool RequestParser::parseRequestLine(const QString &line)
|
|||
const int eqCharPos = param.indexOf('=');
|
||||
if (eqCharPos <= 0) continue; // ignores params without name
|
||||
|
||||
const QByteArrayView nameComponent = param.mid(0, eqCharPos);
|
||||
const QByteArrayView valueComponent = param.mid(eqCharPos + 1);
|
||||
const QByteArrayView nameComponent = param.first(eqCharPos);
|
||||
const QByteArrayView valueComponent = param.sliced(eqCharPos + 1);
|
||||
const QString paramName = QString::fromUtf8(
|
||||
QByteArray::fromPercentEncoding(asQByteArray(nameComponent)).replace('+', ' '));
|
||||
const QByteArray paramValue = valueComponent.isNull()
|
||||
? QByteArray("")
|
||||
: QByteArray::fromPercentEncoding(asQByteArray(valueComponent)).replace('+', ' ');
|
||||
const QByteArray paramValue = QByteArray::fromPercentEncoding(asQByteArray(valueComponent)).replace('+', ' ');
|
||||
|
||||
m_request.query[paramName] = paramValue;
|
||||
}
|
||||
|
@ -272,7 +270,7 @@ bool RequestParser::parsePostMessage(const QByteArrayView data)
|
|||
return false;
|
||||
}
|
||||
|
||||
const QByteArray delimiter = Utils::String::unquote(QStringView(contentType).mid(idx + boundaryFieldName.size())).toLatin1();
|
||||
const QByteArray delimiter = Utils::String::unquote(QStringView(contentType).sliced(idx + boundaryFieldName.size())).toLatin1();
|
||||
if (delimiter.isEmpty())
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "boundary delimiter field empty!";
|
||||
|
@ -281,7 +279,7 @@ bool RequestParser::parsePostMessage(const QByteArrayView data)
|
|||
|
||||
// split data by "dash-boundary"
|
||||
const QByteArray dashDelimiter = QByteArray("--") + delimiter + CRLF;
|
||||
QList<QByteArrayView> multipart = splitToViews(data, dashDelimiter, Qt::SkipEmptyParts);
|
||||
QList<QByteArrayView> multipart = splitToViews(data, dashDelimiter);
|
||||
if (multipart.isEmpty())
|
||||
{
|
||||
qWarning() << Q_FUNC_INFO << "multipart empty";
|
||||
|
@ -312,8 +310,8 @@ bool RequestParser::parseFormData(const QByteArrayView data)
|
|||
return false;
|
||||
}
|
||||
|
||||
const QString headers = QString::fromLatin1(data.mid(0, eohPos));
|
||||
const QByteArrayView payload = viewWithoutEndingWith(data.mid((eohPos + EOH.size()), data.size()), CRLF);
|
||||
const QString headers = QString::fromLatin1(data.first(eohPos));
|
||||
const QByteArrayView payload = viewWithoutEndingWith(data.sliced((eohPos + EOH.size())), CRLF);
|
||||
|
||||
HeaderMap headersMap;
|
||||
const QList<QStringView> headerLines = QStringView(headers).split(QString::fromLatin1(CRLF), Qt::SkipEmptyParts);
|
||||
|
@ -330,14 +328,14 @@ bool RequestParser::parseFormData(const QByteArrayView data)
|
|||
if (idx < 0)
|
||||
continue;
|
||||
|
||||
const QString name = directive.left(idx).trimmed().toString().toLower();
|
||||
const QString value = Utils::String::unquote(directive.mid(idx + 1).trimmed()).toString();
|
||||
const QString name = directive.first(idx).trimmed().toString().toLower();
|
||||
const QString value = Utils::String::unquote(directive.sliced(idx + 1).trimmed()).toString();
|
||||
headersMap[name] = value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!parseHeaderLine(line.toString(), headersMap))
|
||||
if (!parseHeaderLine(line, headersMap))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +346,8 @@ bool RequestParser::parseFormData(const QByteArrayView data)
|
|||
|
||||
if (headersMap.contains(filename))
|
||||
{
|
||||
m_request.files.append({headersMap[filename], headersMap[HEADER_CONTENT_TYPE], payload.toByteArray()});
|
||||
m_request.files.append({.filename = headersMap[filename], .type = headersMap[HEADER_CONTENT_TYPE]
|
||||
, .data = payload.toByteArray()});
|
||||
}
|
||||
else if (headersMap.contains(name))
|
||||
{
|
||||
|
|
|
@ -30,8 +30,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QHash>
|
||||
#include <QHostAddress>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
#include "base/global.h"
|
||||
|
|
|
@ -96,9 +96,9 @@ void DNSUpdater::ipRequestFinished(const DownloadResult &result)
|
|||
const QRegularExpressionMatch ipRegexMatch = QRegularExpression(u"Current IP Address:\\s+([^<]+)</body>"_s).match(QString::fromUtf8(result.data));
|
||||
if (ipRegexMatch.hasMatch())
|
||||
{
|
||||
QString ipStr = ipRegexMatch.captured(1);
|
||||
const QString ipStr = ipRegexMatch.captured(1);
|
||||
qDebug() << Q_FUNC_INFO << "Regular expression captured the following IP:" << ipStr;
|
||||
QHostAddress newIp(ipStr);
|
||||
const QHostAddress newIp {ipStr};
|
||||
if (!newIp.isNull())
|
||||
{
|
||||
if (m_lastIP != newIp)
|
||||
|
|
|
@ -265,38 +265,37 @@ void Net::DownloadManager::applyProxySettings()
|
|||
const auto *proxyManager = ProxyConfigurationManager::instance();
|
||||
const ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||
|
||||
m_proxy = QNetworkProxy(QNetworkProxy::NoProxy);
|
||||
|
||||
if ((proxyConfig.type == Net::ProxyType::None) || (proxyConfig.type == ProxyType::SOCKS4))
|
||||
return;
|
||||
|
||||
// Proxy enabled
|
||||
if (proxyConfig.type == ProxyType::SOCKS5)
|
||||
switch (proxyConfig.type)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "using SOCKS proxy";
|
||||
m_proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "using HTTP proxy";
|
||||
m_proxy.setType(QNetworkProxy::HttpProxy);
|
||||
}
|
||||
case Net::ProxyType::None:
|
||||
case Net::ProxyType::SOCKS4:
|
||||
m_proxy = QNetworkProxy(QNetworkProxy::NoProxy);
|
||||
break;
|
||||
|
||||
m_proxy.setHostName(proxyConfig.ip);
|
||||
m_proxy.setPort(proxyConfig.port);
|
||||
case Net::ProxyType::HTTP:
|
||||
m_proxy = QNetworkProxy(
|
||||
QNetworkProxy::HttpProxy
|
||||
, proxyConfig.ip
|
||||
, proxyConfig.port
|
||||
, (proxyConfig.authEnabled ? proxyConfig.username : QString())
|
||||
, (proxyConfig.authEnabled ? proxyConfig.password : QString()));
|
||||
m_proxy.setCapabilities(proxyConfig.hostnameLookupEnabled
|
||||
? (m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability)
|
||||
: (m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability));
|
||||
break;
|
||||
|
||||
// Authentication?
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
qDebug("Proxy requires authentication, authenticating...");
|
||||
m_proxy.setUser(proxyConfig.username);
|
||||
m_proxy.setPassword(proxyConfig.password);
|
||||
}
|
||||
|
||||
if (proxyConfig.hostnameLookupEnabled)
|
||||
m_proxy.setCapabilities(m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability);
|
||||
else
|
||||
m_proxy.setCapabilities(m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability);
|
||||
case Net::ProxyType::SOCKS5:
|
||||
m_proxy = QNetworkProxy(
|
||||
QNetworkProxy::Socks5Proxy
|
||||
, proxyConfig.ip
|
||||
, proxyConfig.port
|
||||
, (proxyConfig.authEnabled ? proxyConfig.username : QString())
|
||||
, (proxyConfig.authEnabled ? proxyConfig.password : QString()));
|
||||
m_proxy.setCapabilities(proxyConfig.hostnameLookupEnabled
|
||||
? (m_proxy.capabilities() | QNetworkProxy::HostNameLookupCapability)
|
||||
: (m_proxy.capabilities() & ~QNetworkProxy::HostNameLookupCapability));
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
void Net::DownloadManager::processWaitingJobs(const ServiceID &serviceID)
|
||||
|
|
|
@ -148,8 +148,7 @@ void Smtp::sendMail(const QString &from, const QString &to, const QString &subje
|
|||
// Encode the body in base64
|
||||
QString crlfBody = body;
|
||||
const QByteArray b = crlfBody.replace(u"\n"_s, u"\r\n"_s).toUtf8().toBase64();
|
||||
const int ct = b.length();
|
||||
for (int i = 0; i < ct; i += 78)
|
||||
for (int i = 0, end = b.length(); i < end; i += 78)
|
||||
m_message += b.mid(i, 78);
|
||||
m_from = from;
|
||||
m_rcpt = to;
|
||||
|
@ -190,8 +189,12 @@ void Smtp::readyRead()
|
|||
{
|
||||
const int pos = m_buffer.indexOf("\r\n");
|
||||
if (pos < 0) return; // Loop exit condition
|
||||
const QByteArray line = m_buffer.left(pos);
|
||||
const QByteArray line = m_buffer.first(pos);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
m_buffer.slice(pos + 2);
|
||||
#else
|
||||
m_buffer.remove(0, (pos + 2));
|
||||
#endif
|
||||
qDebug() << "Response line:" << line;
|
||||
// Extract response code
|
||||
const QByteArray code = line.left(3);
|
||||
|
|
|
@ -94,7 +94,13 @@ bool Path::isValid() const
|
|||
#if defined(Q_OS_WIN)
|
||||
QStringView view = m_pathStr;
|
||||
if (hasDriveLetter(view))
|
||||
view = view.mid(3);
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
view.slice(3);
|
||||
#else
|
||||
view = view.sliced(3);
|
||||
#endif
|
||||
}
|
||||
|
||||
// \\37 is using base-8 number system
|
||||
const QRegularExpression regex {u"[\\0-\\37:?\"*<>|]"_s};
|
||||
|
@ -147,9 +153,9 @@ Path Path::rootItem() const
|
|||
#ifdef Q_OS_WIN
|
||||
// should be `c:/` instead of `c:`
|
||||
if ((slashIndex == 2) && hasDriveLetter(m_pathStr))
|
||||
return createUnchecked(m_pathStr.left(slashIndex + 1));
|
||||
return createUnchecked(m_pathStr.first(slashIndex + 1));
|
||||
#endif
|
||||
return createUnchecked(m_pathStr.left(slashIndex));
|
||||
return createUnchecked(m_pathStr.first(slashIndex));
|
||||
}
|
||||
|
||||
Path Path::parentPath() const
|
||||
|
@ -167,9 +173,9 @@ Path Path::parentPath() const
|
|||
// should be `c:/` instead of `c:`
|
||||
// Windows "drive letter" is limited to one alphabet
|
||||
if ((slashIndex == 2) && hasDriveLetter(m_pathStr))
|
||||
return (m_pathStr.size() == 3) ? Path() : createUnchecked(m_pathStr.left(slashIndex + 1));
|
||||
return (m_pathStr.size() == 3) ? Path() : createUnchecked(m_pathStr.first(slashIndex + 1));
|
||||
#endif
|
||||
return createUnchecked(m_pathStr.left(slashIndex));
|
||||
return createUnchecked(m_pathStr.first(slashIndex));
|
||||
}
|
||||
|
||||
QString Path::filename() const
|
||||
|
@ -178,7 +184,7 @@ QString Path::filename() const
|
|||
if (slashIndex == -1)
|
||||
return m_pathStr;
|
||||
|
||||
return m_pathStr.mid(slashIndex + 1);
|
||||
return m_pathStr.sliced(slashIndex + 1);
|
||||
}
|
||||
|
||||
QString Path::extension() const
|
||||
|
@ -188,9 +194,9 @@ QString Path::extension() const
|
|||
return (u"." + suffix);
|
||||
|
||||
const int slashIndex = m_pathStr.lastIndexOf(u'/');
|
||||
const auto filename = QStringView(m_pathStr).mid(slashIndex + 1);
|
||||
const auto filename = QStringView(m_pathStr).sliced(slashIndex + 1);
|
||||
const int dotIndex = filename.lastIndexOf(u'.', -2);
|
||||
return ((dotIndex == -1) ? QString() : filename.mid(dotIndex).toString());
|
||||
return ((dotIndex == -1) ? QString() : filename.sliced(dotIndex).toString());
|
||||
}
|
||||
|
||||
bool Path::hasExtension(const QStringView ext) const
|
||||
|
@ -293,7 +299,7 @@ Path Path::commonPath(const Path &left, const Path &right)
|
|||
if (commonItemsCount > 0)
|
||||
commonPathSize += (commonItemsCount - 1); // size of intermediate separators
|
||||
|
||||
return Path::createUnchecked(left.m_pathStr.left(commonPathSize));
|
||||
return Path::createUnchecked(left.m_pathStr.first(commonPathSize));
|
||||
}
|
||||
|
||||
Path Path::findRootFolder(const PathList &filePaths)
|
||||
|
@ -322,7 +328,13 @@ void Path::stripRootFolder(PathList &filePaths)
|
|||
return;
|
||||
|
||||
for (Path &filePath : filePaths)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
filePath.m_pathStr.slice(commonRootFolder.m_pathStr.size() + 1);
|
||||
#else
|
||||
filePath.m_pathStr.remove(0, (commonRootFolder.m_pathStr.size() + 1));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void Path::addRootFolder(PathList &filePaths, const Path &rootFolder)
|
||||
|
|
|
@ -359,6 +359,19 @@ void Preferences::setStatusbarDisplayed(const bool displayed)
|
|||
setValue(u"Preferences/General/StatusbarDisplayed"_s, displayed);
|
||||
}
|
||||
|
||||
bool Preferences::isStatusbarFreeDiskSpaceDisplayed() const
|
||||
{
|
||||
return value(u"Preferences/General/StatusbarFreeDiskSpaceDisplayed"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setStatusbarFreeDiskSpaceDisplayed(const bool displayed)
|
||||
{
|
||||
if (displayed == isStatusbarFreeDiskSpaceDisplayed())
|
||||
return;
|
||||
|
||||
setValue(u"Preferences/General/StatusbarFreeDiskSpaceDisplayed"_s, displayed);
|
||||
}
|
||||
|
||||
bool Preferences::isStatusbarExternalIPDisplayed() const
|
||||
{
|
||||
return value(u"Preferences/General/StatusbarExternalIPDisplayed"_s, false);
|
||||
|
@ -655,6 +668,47 @@ void Preferences::setSearchEnabled(const bool enabled)
|
|||
setValue(u"Preferences/Search/SearchEnabled"_s, enabled);
|
||||
}
|
||||
|
||||
int Preferences::searchHistoryLength() const
|
||||
{
|
||||
const int val = value(u"Search/HistoryLength"_s, 50);
|
||||
return std::clamp(val, 0, 99);
|
||||
}
|
||||
|
||||
void Preferences::setSearchHistoryLength(const int length)
|
||||
{
|
||||
const int clampedLength = std::clamp(length, 0, 99);
|
||||
if (clampedLength == searchHistoryLength())
|
||||
return;
|
||||
|
||||
setValue(u"Search/HistoryLength"_s, clampedLength);
|
||||
}
|
||||
|
||||
bool Preferences::storeOpenedSearchTabs() const
|
||||
{
|
||||
return value(u"Search/StoreOpenedSearchTabs"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setStoreOpenedSearchTabs(const bool enabled)
|
||||
{
|
||||
if (enabled == storeOpenedSearchTabs())
|
||||
return;
|
||||
|
||||
setValue(u"Search/StoreOpenedSearchTabs"_s, enabled);
|
||||
}
|
||||
|
||||
bool Preferences::storeOpenedSearchTabResults() const
|
||||
{
|
||||
return value(u"Search/StoreOpenedSearchTabResults"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setStoreOpenedSearchTabResults(const bool enabled)
|
||||
{
|
||||
if (enabled == storeOpenedSearchTabResults())
|
||||
return;
|
||||
|
||||
setValue(u"Search/StoreOpenedSearchTabResults"_s, enabled);
|
||||
}
|
||||
|
||||
bool Preferences::isWebUIEnabled() const
|
||||
{
|
||||
#ifdef DISABLE_GUI
|
||||
|
@ -2013,6 +2067,19 @@ void Preferences::setAddNewTorrentDialogSavePathHistoryLength(const int value)
|
|||
setValue(u"AddNewTorrentDialog/SavePathHistoryLength"_s, clampedValue);
|
||||
}
|
||||
|
||||
bool Preferences::isAddNewTorrentDialogAttached() const
|
||||
{
|
||||
return value(u"AddNewTorrentDialog/Attached"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setAddNewTorrentDialogAttached(const bool attached)
|
||||
{
|
||||
if (attached == isAddNewTorrentDialogAttached())
|
||||
return;
|
||||
|
||||
setValue(u"AddNewTorrentDialog/Attached"_s, attached);
|
||||
}
|
||||
|
||||
void Preferences::apply()
|
||||
{
|
||||
if (SettingsStorage::instance()->save())
|
||||
|
|
|
@ -119,6 +119,8 @@ public:
|
|||
void setHideZeroComboValues(int n);
|
||||
bool isStatusbarDisplayed() const;
|
||||
void setStatusbarDisplayed(bool displayed);
|
||||
bool isStatusbarFreeDiskSpaceDisplayed() const;
|
||||
void setStatusbarFreeDiskSpaceDisplayed(bool displayed);
|
||||
bool isStatusbarExternalIPDisplayed() const;
|
||||
void setStatusbarExternalIPDisplayed(bool displayed);
|
||||
bool isToolbarDisplayed() const;
|
||||
|
@ -172,6 +174,14 @@ public:
|
|||
bool isSearchEnabled() const;
|
||||
void setSearchEnabled(bool enabled);
|
||||
|
||||
// Search UI
|
||||
int searchHistoryLength() const;
|
||||
void setSearchHistoryLength(int length);
|
||||
bool storeOpenedSearchTabs() const;
|
||||
void setStoreOpenedSearchTabs(bool enabled);
|
||||
bool storeOpenedSearchTabResults() const;
|
||||
void setStoreOpenedSearchTabResults(bool enabled);
|
||||
|
||||
// HTTP Server
|
||||
bool isWebUIEnabled() const;
|
||||
void setWebUIEnabled(bool enabled);
|
||||
|
@ -425,6 +435,8 @@ public:
|
|||
void setAddNewTorrentDialogTopLevel(bool value);
|
||||
int addNewTorrentDialogSavePathHistoryLength() const;
|
||||
void setAddNewTorrentDialogSavePathHistoryLength(int value);
|
||||
bool isAddNewTorrentDialogAttached() const;
|
||||
void setAddNewTorrentDialogAttached(bool attached);
|
||||
|
||||
public slots:
|
||||
void setStatusFilterState(bool checked);
|
||||
|
|
|
@ -73,7 +73,7 @@ void RSS::Private::FeedSerializer::store(const Path &dataFileName, const QList<Q
|
|||
arr << jsonObj;
|
||||
}
|
||||
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(dataFileName, QJsonDocument(arr).toJson());
|
||||
const nonstd::expected<void, QString> result = Utils::IO::saveToFile(dataFileName, QJsonDocument(arr).toJson(QJsonDocument::Compact));
|
||||
if (!result)
|
||||
{
|
||||
LogMsg(tr("Failed to save RSS feed in '%1', Reason: %2").arg(dataFileName.toString(), result.error())
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "base/addtorrentmanager.h"
|
||||
#include "base/asyncfilestorage.h"
|
||||
#include "base/bittorrent/addtorrenterror.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrentdescriptor.h"
|
||||
#include "base/global.h"
|
||||
|
@ -375,10 +376,24 @@ void AutoDownloader::handleTorrentAdded(const QString &source)
|
|||
}
|
||||
}
|
||||
|
||||
void AutoDownloader::handleAddTorrentFailed(const QString &source)
|
||||
void AutoDownloader::handleAddTorrentFailed(const QString &source, const BitTorrent::AddTorrentError &error)
|
||||
{
|
||||
m_waitingJobs.remove(source);
|
||||
// TODO: Re-schedule job here.
|
||||
const auto job = m_waitingJobs.take(source);
|
||||
if (!job)
|
||||
return;
|
||||
|
||||
if (error.kind == BitTorrent::AddTorrentError::DuplicateTorrent)
|
||||
{
|
||||
if (Feed *feed = Session::instance()->feedByURL(job->feedURL))
|
||||
{
|
||||
if (Article *article = feed->articleByGUID(job->articleData.value(Article::KeyId).toString()))
|
||||
article->markAsRead();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Re-schedule job here.
|
||||
}
|
||||
}
|
||||
|
||||
void AutoDownloader::handleNewArticle(const Article *article)
|
||||
|
|
|
@ -47,6 +47,11 @@ class Application;
|
|||
class AsyncFileStorage;
|
||||
struct ProcessingJob;
|
||||
|
||||
namespace BitTorrent
|
||||
{
|
||||
struct AddTorrentError;
|
||||
}
|
||||
|
||||
namespace RSS
|
||||
{
|
||||
class Article;
|
||||
|
@ -111,7 +116,7 @@ namespace RSS
|
|||
private slots:
|
||||
void process();
|
||||
void handleTorrentAdded(const QString &source);
|
||||
void handleAddTorrentFailed(const QString &url);
|
||||
void handleAddTorrentFailed(const QString &url, const BitTorrent::AddTorrentError &error);
|
||||
void handleNewArticle(const Article *article);
|
||||
void handleFeedURLChanged(Feed *feed, const QString &oldURL);
|
||||
|
||||
|
|
|
@ -184,14 +184,10 @@ QString computeEpisodeName(const QString &article)
|
|||
for (int i = 1; i <= match.lastCapturedIndex(); ++i)
|
||||
{
|
||||
const QString cap = match.captured(i);
|
||||
|
||||
if (cap.isEmpty())
|
||||
continue;
|
||||
|
||||
bool isInt = false;
|
||||
const int x = cap.toInt(&isInt);
|
||||
|
||||
ret.append(isInt ? QString::number(x) : cap);
|
||||
ret.append(cap);
|
||||
}
|
||||
return ret.join(u'x');
|
||||
}
|
||||
|
@ -293,20 +289,26 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitl
|
|||
if (!matcher.hasMatch())
|
||||
return false;
|
||||
|
||||
const QString season {matcher.captured(1)};
|
||||
const QStringList episodes {matcher.captured(2).split(u';')};
|
||||
const QStringView season {matcher.capturedView(1)};
|
||||
const QList<QStringView> episodes {matcher.capturedView(2).split(u';')};
|
||||
const int seasonOurs {season.toInt()};
|
||||
|
||||
for (QString episode : episodes)
|
||||
for (QStringView episode : episodes)
|
||||
{
|
||||
if (episode.isEmpty())
|
||||
continue;
|
||||
|
||||
// We need to trim leading zeroes, but if it's all zeros then we want episode zero.
|
||||
while ((episode.size() > 1) && episode.startsWith(u'0'))
|
||||
episode = episode.right(episode.size() - 1);
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
episode.slice(1);
|
||||
#else
|
||||
episode = episode.sliced(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (episode.indexOf(u'-') != -1)
|
||||
if (episode.contains(u'-'))
|
||||
{ // Range detected
|
||||
const QString partialPattern1 {u"\\bs0?(\\d{1,4})[ -_\\.]?e(0?\\d{1,4})(?:\\D|\\b)"_s};
|
||||
const QString partialPattern2 {u"\\b(\\d{1,4})x(0?\\d{1,4})(?:\\D|\\b)"_s};
|
||||
|
@ -323,24 +325,25 @@ bool AutoDownloadRule::matchesEpisodeFilterExpression(const QString &articleTitl
|
|||
|
||||
if (matched)
|
||||
{
|
||||
const int seasonTheirs {matcher.captured(1).toInt()};
|
||||
const int episodeTheirs {matcher.captured(2).toInt()};
|
||||
const int seasonTheirs {matcher.capturedView(1).toInt()};
|
||||
const int episodeTheirs {matcher.capturedView(2).toInt()};
|
||||
|
||||
if (episode.endsWith(u'-'))
|
||||
{ // Infinite range
|
||||
const int episodeOurs {QStringView(episode).left(episode.size() - 1).toInt()};
|
||||
const int episodeOurs {QStringView(episode).chopped(1).toInt()};
|
||||
if (((seasonTheirs == seasonOurs) && (episodeTheirs >= episodeOurs)) || (seasonTheirs > seasonOurs))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{ // Normal range
|
||||
const QStringList range {episode.split(u'-')};
|
||||
const QList<QStringView> range {episode.split(u'-')};
|
||||
Q_ASSERT(range.size() == 2);
|
||||
if (range.first().toInt() > range.last().toInt())
|
||||
continue; // Ignore this subrule completely
|
||||
|
||||
const int episodeOursFirst {range.first().toInt()};
|
||||
const int episodeOursLast {range.last().toInt()};
|
||||
if (episodeOursFirst > episodeOursLast)
|
||||
continue; // Ignore this subrule completely
|
||||
|
||||
if ((seasonTheirs == seasonOurs) && ((episodeOursFirst <= episodeTheirs) && (episodeOursLast >= episodeTheirs)))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2024 Jonathan Ketchker
|
||||
* Copyright (C) 2015-2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
* Copyright (C) 2010 Arnaud Demaiziere <arnaud@qbittorrent.org>
|
||||
*
|
||||
|
@ -56,19 +56,22 @@
|
|||
|
||||
const QString KEY_UID = u"uid"_s;
|
||||
const QString KEY_URL = u"url"_s;
|
||||
const QString KEY_REFRESHINTERVAL = u"refreshInterval"_s;
|
||||
const QString KEY_TITLE = u"title"_s;
|
||||
const QString KEY_LASTBUILDDATE = u"lastBuildDate"_s;
|
||||
const QString KEY_ISLOADING = u"isLoading"_s;
|
||||
const QString KEY_HASERROR = u"hasError"_s;
|
||||
const QString KEY_ARTICLES = u"articles"_s;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace RSS;
|
||||
|
||||
Feed::Feed(const QUuid &uid, const QString &url, const QString &path, Session *session)
|
||||
Feed::Feed(Session *session, const QUuid &uid, const QString &url, const QString &path, const std::chrono::seconds refreshInterval)
|
||||
: Item(path)
|
||||
, m_session(session)
|
||||
, m_uid(uid)
|
||||
, m_url(url)
|
||||
, m_session {session}
|
||||
, m_uid {uid}
|
||||
, m_url {url}
|
||||
, m_refreshInterval {refreshInterval}
|
||||
{
|
||||
const auto uidHex = QString::fromLatin1(m_uid.toRfc4122().toHex());
|
||||
m_dataFileName = Path(uidHex + u".json");
|
||||
|
@ -327,9 +330,9 @@ bool Feed::addArticle(const QVariantHash &articleData)
|
|||
|
||||
// Insertion sort
|
||||
const int maxArticles = m_session->maxArticlesPerFeed();
|
||||
const auto lowerBound = std::lower_bound(m_articlesByDate.begin(), m_articlesByDate.end()
|
||||
, articleData.value(Article::KeyDate).toDateTime(), Article::articleDateRecentThan);
|
||||
if ((lowerBound - m_articlesByDate.begin()) >= maxArticles)
|
||||
const auto lowerBound = std::lower_bound(m_articlesByDate.cbegin(), m_articlesByDate.cend()
|
||||
, articleData.value(Article::KeyDate).toDateTime(), Article::articleDateRecentThan);
|
||||
if ((lowerBound - m_articlesByDate.cbegin()) >= maxArticles)
|
||||
return false; // we reach max articles
|
||||
|
||||
auto *article = new Article(this, articleData);
|
||||
|
@ -462,6 +465,20 @@ Path Feed::iconPath() const
|
|||
return m_iconPath;
|
||||
}
|
||||
|
||||
std::chrono::seconds Feed::refreshInterval() const
|
||||
{
|
||||
return m_refreshInterval;
|
||||
}
|
||||
|
||||
void Feed::setRefreshInterval(const std::chrono::seconds refreshInterval)
|
||||
{
|
||||
if (refreshInterval == m_refreshInterval)
|
||||
return;
|
||||
|
||||
const std::chrono::seconds oldRefreshInterval = std::exchange(m_refreshInterval, refreshInterval);
|
||||
emit refreshIntervalChanged(oldRefreshInterval);
|
||||
}
|
||||
|
||||
void Feed::setURL(const QString &url)
|
||||
{
|
||||
const QString oldURL = m_url;
|
||||
|
@ -474,6 +491,8 @@ QJsonValue Feed::toJsonValue(const bool withData) const
|
|||
QJsonObject jsonObj;
|
||||
jsonObj.insert(KEY_UID, uid().toString());
|
||||
jsonObj.insert(KEY_URL, url());
|
||||
if (refreshInterval() > 0s)
|
||||
jsonObj.insert(KEY_REFRESHINTERVAL, static_cast<qint64>(refreshInterval().count()));
|
||||
|
||||
if (withData)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2024 Jonathan Ketchker
|
||||
* Copyright (C) 2015-2022 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
* Copyright (C) 2010 Arnaud Demaiziere <arnaud@qbittorrent.org>
|
||||
*
|
||||
|
@ -31,6 +31,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <QtContainerFwd>
|
||||
#include <QBasicTimer>
|
||||
#include <QHash>
|
||||
|
@ -68,7 +70,7 @@ namespace RSS
|
|||
|
||||
friend class Session;
|
||||
|
||||
Feed(const QUuid &uid, const QString &url, const QString &path, Session *session);
|
||||
Feed(Session *session, const QUuid &uid, const QString &url, const QString &path, std::chrono::seconds refreshInterval);
|
||||
~Feed() override;
|
||||
|
||||
public:
|
||||
|
@ -87,6 +89,9 @@ namespace RSS
|
|||
Article *articleByGUID(const QString &guid) const;
|
||||
Path iconPath() const;
|
||||
|
||||
std::chrono::seconds refreshInterval() const;
|
||||
void setRefreshInterval(std::chrono::seconds refreshInterval);
|
||||
|
||||
QJsonValue toJsonValue(bool withData = false) const override;
|
||||
|
||||
signals:
|
||||
|
@ -94,6 +99,7 @@ namespace RSS
|
|||
void titleChanged(Feed *feed = nullptr);
|
||||
void stateChanged(Feed *feed = nullptr);
|
||||
void urlChanged(const QString &oldURL);
|
||||
void refreshIntervalChanged(std::chrono::seconds oldRefreshInterval);
|
||||
|
||||
private slots:
|
||||
void handleSessionProcessingEnabledChanged(bool enabled);
|
||||
|
@ -123,6 +129,7 @@ namespace RSS
|
|||
Private::FeedSerializer *m_serializer = nullptr;
|
||||
const QUuid m_uid;
|
||||
QString m_url;
|
||||
std::chrono::seconds m_refreshInterval;
|
||||
QString m_title;
|
||||
QString m_lastBuildDate;
|
||||
bool m_hasError = false;
|
||||
|
|
|
@ -97,7 +97,7 @@ QStringList Item::expandPath(const QString &path)
|
|||
int index = 0;
|
||||
while ((index = path.indexOf(Item::PathSeparator, index)) >= 0)
|
||||
{
|
||||
result << path.left(index);
|
||||
result << path.first(index);
|
||||
++index;
|
||||
}
|
||||
result << path;
|
||||
|
@ -108,11 +108,11 @@ QStringList Item::expandPath(const QString &path)
|
|||
QString Item::parentPath(const QString &path)
|
||||
{
|
||||
const int pos = path.lastIndexOf(Item::PathSeparator);
|
||||
return (pos >= 0) ? path.left(pos) : QString();
|
||||
return (pos >= 0) ? path.first(pos) : QString();
|
||||
}
|
||||
|
||||
QString Item::relativeName(const QString &path)
|
||||
{
|
||||
int pos;
|
||||
return ((pos = path.lastIndexOf(Item::PathSeparator)) >= 0 ? path.right(path.size() - (pos + 1)) : path);
|
||||
const int pos = path.lastIndexOf(Item::PathSeparator);
|
||||
return (pos >= 0) ? path.sliced(pos + 1) : path;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2015-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2015-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2017-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2024 Jonathan Ketchker
|
||||
* Copyright (C) 2017 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
* Copyright (C) 2010 Arnaud Demaiziere <arnaud@qbittorrent.org>
|
||||
*
|
||||
|
@ -56,6 +56,7 @@ const QString CONF_FOLDER_NAME = u"rss"_s;
|
|||
const QString DATA_FOLDER_NAME = u"rss/articles"_s;
|
||||
const QString FEEDS_FILE_NAME = u"feeds.json"_s;
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace RSS;
|
||||
|
||||
QPointer<Session> Session::m_instance = nullptr;
|
||||
|
@ -94,12 +95,10 @@ Session::Session()
|
|||
m_workingThread->start();
|
||||
load();
|
||||
|
||||
m_refreshTimer.setSingleShot(true);
|
||||
connect(&m_refreshTimer, &QTimer::timeout, this, &Session::refresh);
|
||||
if (isProcessingEnabled())
|
||||
{
|
||||
m_refreshTimer.start(std::chrono::minutes(refreshInterval()));
|
||||
refresh();
|
||||
}
|
||||
|
||||
// Remove legacy/corrupted settings
|
||||
// (at least on Windows, QSettings is case-insensitive and it can get
|
||||
|
@ -138,19 +137,20 @@ Session *Session::instance()
|
|||
return m_instance;
|
||||
}
|
||||
|
||||
nonstd::expected<void, QString> Session::addFolder(const QString &path)
|
||||
nonstd::expected<Folder *, QString> Session::addFolder(const QString &path)
|
||||
{
|
||||
const nonstd::expected<Folder *, QString> result = prepareItemDest(path);
|
||||
if (!result)
|
||||
return result.get_unexpected();
|
||||
|
||||
auto *destFolder = result.value();
|
||||
addItem(new Folder(path), destFolder);
|
||||
auto *folder = new Folder(path);
|
||||
addItem(folder, destFolder);
|
||||
store();
|
||||
return {};
|
||||
return folder;
|
||||
}
|
||||
|
||||
nonstd::expected<void, QString> Session::addFeed(const QString &url, const QString &path)
|
||||
nonstd::expected<Feed *, QString> Session::addFeed(const QString &url, const QString &path, const std::chrono::seconds refreshInterval)
|
||||
{
|
||||
if (m_feedsByURL.contains(url))
|
||||
return nonstd::make_unexpected(tr("RSS feed with given URL already exists: %1.").arg(url));
|
||||
|
@ -160,13 +160,13 @@ nonstd::expected<void, QString> Session::addFeed(const QString &url, const QStri
|
|||
return result.get_unexpected();
|
||||
|
||||
auto *destFolder = result.value();
|
||||
auto *feed = new Feed(generateUID(), url, path, this);
|
||||
auto *feed = new Feed(this, generateUID(), url, path, refreshInterval);
|
||||
addItem(feed, destFolder);
|
||||
store();
|
||||
if (isProcessingEnabled())
|
||||
feed->refresh();
|
||||
refreshFeed(feed, std::chrono::system_clock::now());
|
||||
|
||||
return {};
|
||||
return feed;
|
||||
}
|
||||
|
||||
nonstd::expected<void, QString> Session::setFeedURL(const QString &path, const QString &url)
|
||||
|
@ -192,7 +192,7 @@ nonstd::expected<void, QString> Session::setFeedURL(Feed *feed, const QString &u
|
|||
feed->setURL(url);
|
||||
store();
|
||||
if (isProcessingEnabled())
|
||||
feed->refresh();
|
||||
refreshFeed(feed, std::chrono::system_clock::now());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -214,14 +214,20 @@ nonstd::expected<void, QString> Session::moveItem(Item *item, const QString &des
|
|||
Q_ASSERT(item);
|
||||
Q_ASSERT(item != rootFolder());
|
||||
|
||||
if (item->path() == destPath)
|
||||
return {};
|
||||
|
||||
if (auto *folder = static_cast<Folder *>(item)) // if `item` is a `Folder`
|
||||
{
|
||||
if (destPath.startsWith(folder->path() + Item::PathSeparator))
|
||||
return nonstd::make_unexpected(tr("Can't move a folder into itself or its subfolders."));
|
||||
}
|
||||
|
||||
const nonstd::expected<Folder *, QString> result = prepareItemDest(destPath);
|
||||
if (!result)
|
||||
return result.get_unexpected();
|
||||
|
||||
auto *destFolder = result.value();
|
||||
if (static_cast<Item *>(destFolder) == item)
|
||||
return nonstd::make_unexpected(tr("Couldn't move folder into itself."));
|
||||
|
||||
auto *srcFolder = static_cast<Folder *>(m_itemsByPath.value(Item::parentPath(item->path())));
|
||||
if (srcFolder != destFolder)
|
||||
{
|
||||
|
@ -314,7 +320,7 @@ bool Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
|
|||
QString url = val.toString();
|
||||
if (url.isEmpty())
|
||||
url = key;
|
||||
addFeedToFolder(generateUID(), url, key, folder);
|
||||
addFeedToFolder(generateUID(), url, key, folder, 0s);
|
||||
updated = true;
|
||||
}
|
||||
else if (val.isObject())
|
||||
|
@ -354,7 +360,9 @@ bool Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
|
|||
updated = true;
|
||||
}
|
||||
|
||||
addFeedToFolder(uid, valObj[u"url"].toString(), key, folder);
|
||||
const auto refreshInterval = std::chrono::seconds(valObj[u"refreshInterval"].toInteger());
|
||||
|
||||
addFeedToFolder(uid, valObj[u"url"].toString(), key, folder, refreshInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -385,8 +393,14 @@ void Session::loadLegacy()
|
|||
uint i = 0;
|
||||
for (QString legacyPath : legacyFeedPaths)
|
||||
{
|
||||
if (Item::PathSeparator == legacyPath[0])
|
||||
if (legacyPath.startsWith(Item::PathSeparator))
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
|
||||
legacyPath.slice(1);
|
||||
#else
|
||||
legacyPath.remove(0, 1);
|
||||
#endif
|
||||
}
|
||||
const QString parentFolderPath = Item::parentPath(legacyPath);
|
||||
const QString feedUrl = Item::relativeName(legacyPath);
|
||||
|
||||
|
@ -404,7 +418,7 @@ void Session::loadLegacy()
|
|||
void Session::store()
|
||||
{
|
||||
m_confFileStorage->store(Path(FEEDS_FILE_NAME)
|
||||
, QJsonDocument(rootFolder()->toJsonValue().toObject()).toJson());
|
||||
, QJsonDocument(rootFolder()->toJsonValue().toObject()).toJson());
|
||||
}
|
||||
|
||||
nonstd::expected<Folder *, QString> Session::prepareItemDest(const QString &path)
|
||||
|
@ -430,9 +444,9 @@ Folder *Session::addSubfolder(const QString &name, Folder *parentFolder)
|
|||
return folder;
|
||||
}
|
||||
|
||||
Feed *Session::addFeedToFolder(const QUuid &uid, const QString &url, const QString &name, Folder *parentFolder)
|
||||
Feed *Session::addFeedToFolder(const QUuid &uid, const QString &url, const QString &name, Folder *parentFolder, const std::chrono::seconds refreshInterval)
|
||||
{
|
||||
auto *feed = new Feed(uid, url, Item::joinPath(parentFolder->path(), name), this);
|
||||
auto *feed = new Feed(this, uid, url, Item::joinPath(parentFolder->path(), name), refreshInterval);
|
||||
addItem(feed, parentFolder);
|
||||
return feed;
|
||||
}
|
||||
|
@ -454,8 +468,25 @@ void Session::addItem(Item *item, Folder *destFolder)
|
|||
|
||||
emit feedURLChanged(feed, oldURL);
|
||||
});
|
||||
connect(feed, &Feed::refreshIntervalChanged, this, [this, feed](const std::chrono::seconds oldRefreshInterval)
|
||||
{
|
||||
store();
|
||||
|
||||
std::chrono::system_clock::time_point &nextRefresh = m_refreshTimepoints[feed];
|
||||
if (nextRefresh > std::chrono::system_clock::time_point())
|
||||
nextRefresh += feed->refreshInterval() - oldRefreshInterval;
|
||||
|
||||
if (isProcessingEnabled())
|
||||
{
|
||||
const std::chrono::seconds oldEffectiveRefreshInterval = (oldRefreshInterval > 0s)
|
||||
? oldRefreshInterval : std::chrono::minutes(refreshInterval());
|
||||
if (feed->refreshInterval() < oldEffectiveRefreshInterval)
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
m_feedsByUID[feed->uid()] = feed;
|
||||
m_feedsByURL[feed->url()] = feed;
|
||||
m_refreshTimepoints.emplace(feed, std::chrono::system_clock::time_point());
|
||||
}
|
||||
|
||||
connect(item, &Item::pathChanged, this, &Session::itemPathChanged);
|
||||
|
@ -476,14 +507,9 @@ void Session::setProcessingEnabled(const bool enabled)
|
|||
{
|
||||
m_storeProcessingEnabled = enabled;
|
||||
if (enabled)
|
||||
{
|
||||
m_refreshTimer.start(std::chrono::minutes(refreshInterval()));
|
||||
refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_refreshTimer.stop();
|
||||
}
|
||||
|
||||
emit processingStateChanged(enabled);
|
||||
}
|
||||
|
@ -554,6 +580,7 @@ void Session::handleItemAboutToBeDestroyed(Item *item)
|
|||
{
|
||||
m_feedsByUID.remove(feed->uid());
|
||||
m_feedsByURL.remove(feed->url());
|
||||
m_refreshTimepoints.remove(feed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -592,6 +619,28 @@ void Session::setMaxArticlesPerFeed(const int n)
|
|||
|
||||
void Session::refresh()
|
||||
{
|
||||
// NOTE: Should we allow manually refreshing for disabled session?
|
||||
rootFolder()->refresh();
|
||||
const auto currentTimepoint = std::chrono::system_clock::now();
|
||||
std::chrono::seconds nextRefreshInterval = 0s;
|
||||
for (auto it = m_refreshTimepoints.begin(); it != m_refreshTimepoints.end(); ++it)
|
||||
{
|
||||
Feed *feed = it.key();
|
||||
std::chrono::system_clock::time_point &timepoint = it.value();
|
||||
|
||||
if (timepoint <= currentTimepoint)
|
||||
timepoint = refreshFeed(feed, currentTimepoint);
|
||||
|
||||
const auto interval = std::chrono::duration_cast<std::chrono::seconds>(timepoint - currentTimepoint);
|
||||
if ((interval < nextRefreshInterval) || (nextRefreshInterval == 0s))
|
||||
nextRefreshInterval = interval;
|
||||
}
|
||||
|
||||
m_refreshTimer.start(nextRefreshInterval);
|
||||
}
|
||||
|
||||
std::chrono::system_clock::time_point Session::refreshFeed(Feed *feed, const std::chrono::system_clock::time_point ¤tTimepoint)
|
||||
{
|
||||
feed->refresh();
|
||||
const std::chrono::seconds feedRefreshInterval = feed->refreshInterval();
|
||||
const std::chrono::seconds effectiveRefreshInterval = (feedRefreshInterval > 0s) ? feedRefreshInterval : std::chrono::minutes(refreshInterval());
|
||||
return currentTimepoint + effectiveRefreshInterval;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2017-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2024 Jonathan Ketchker
|
||||
* Copyright (C) 2017 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2010 Christophe Dumez <chris@qbittorrent.org>
|
||||
* Copyright (C) 2010 Arnaud Demaiziere <arnaud@qbittorrent.org>
|
||||
*
|
||||
|
@ -35,26 +35,20 @@
|
|||
* RSS Session configuration file format (JSON):
|
||||
*
|
||||
* =============== BEGIN ===============
|
||||
*
|
||||
{
|
||||
* "folder1":
|
||||
{
|
||||
* "subfolder1":
|
||||
{
|
||||
* "Feed name 1 (Alias)":
|
||||
{
|
||||
* {
|
||||
* "folder1": {
|
||||
* "subfolder1": {
|
||||
* "Feed name 1 (Alias)": {
|
||||
* "uid": "feed unique identifier",
|
||||
* "url": "http://some-feed-url1"
|
||||
* }
|
||||
* "Feed name 2 (Alias)":
|
||||
{
|
||||
* "Feed name 2 (Alias)": {
|
||||
* "uid": "feed unique identifier",
|
||||
* "url": "http://some-feed-url2"
|
||||
* }
|
||||
* },
|
||||
* "subfolder2": {},
|
||||
* "Feed name 3 (Alias)":
|
||||
{
|
||||
* "Feed name 3 (Alias)": {
|
||||
* "uid": "feed unique identifier",
|
||||
* "url": "http://some-feed-url3"
|
||||
* }
|
||||
|
@ -120,8 +114,8 @@ namespace RSS
|
|||
std::chrono::seconds fetchDelay() const;
|
||||
void setFetchDelay(std::chrono::seconds delay);
|
||||
|
||||
nonstd::expected<void, QString> addFolder(const QString &path);
|
||||
nonstd::expected<void, QString> addFeed(const QString &url, const QString &path);
|
||||
nonstd::expected<Folder *, QString> addFolder(const QString &path);
|
||||
nonstd::expected<Feed *, QString> addFeed(const QString &url, const QString &path, std::chrono::seconds refreshInterval = {});
|
||||
nonstd::expected<void, QString> setFeedURL(const QString &path, const QString &url);
|
||||
nonstd::expected<void, QString> setFeedURL(Feed *feed, const QString &url);
|
||||
nonstd::expected<void, QString> moveItem(const QString &itemPath, const QString &destPath);
|
||||
|
@ -135,9 +129,6 @@ namespace RSS
|
|||
|
||||
Folder *rootFolder() const;
|
||||
|
||||
public slots:
|
||||
void refresh();
|
||||
|
||||
signals:
|
||||
void processingStateChanged(bool enabled);
|
||||
void maxArticlesPerFeedChanged(int n);
|
||||
|
@ -160,8 +151,10 @@ namespace RSS
|
|||
void store();
|
||||
nonstd::expected<Folder *, QString> prepareItemDest(const QString &path);
|
||||
Folder *addSubfolder(const QString &name, Folder *parentFolder);
|
||||
Feed *addFeedToFolder(const QUuid &uid, const QString &url, const QString &name, Folder *parentFolder);
|
||||
Feed *addFeedToFolder(const QUuid &uid, const QString &url, const QString &name, Folder *parentFolder, std::chrono::seconds refreshInterval);
|
||||
void addItem(Item *item, Folder *destFolder);
|
||||
void refresh();
|
||||
std::chrono::system_clock::time_point refreshFeed(Feed *feed, const std::chrono::system_clock::time_point ¤tTimepoint);
|
||||
|
||||
static QPointer<Session> m_instance;
|
||||
|
||||
|
@ -176,5 +169,6 @@ namespace RSS
|
|||
QHash<QString, Item *> m_itemsByPath;
|
||||
QHash<QUuid, Feed *> m_feedsByUID;
|
||||
QHash<QString, Feed *> m_feedsByURL;
|
||||
QHash<Feed *, std::chrono::system_clock::time_point> m_refreshTimepoints;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -41,7 +41,10 @@ SearchDownloadHandler::SearchDownloadHandler(const QString &pluginName, const QS
|
|||
, m_manager {manager}
|
||||
, m_downloadProcess {new QProcess(this)}
|
||||
{
|
||||
m_downloadProcess->setEnvironment(QProcess::systemEnvironment());
|
||||
m_downloadProcess->setProcessEnvironment(m_manager->proxyEnvironment());
|
||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
m_downloadProcess->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||
#endif
|
||||
connect(m_downloadProcess, qOverload<int, QProcess::ExitStatus>(&QProcess::finished)
|
||||
, this, &SearchDownloadHandler::downloadProcessFinished);
|
||||
const QStringList params
|
||||
|
|
|
@ -70,7 +70,11 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
|
|||
, m_searchTimeout {new QTimer(this)}
|
||||
{
|
||||
// Load environment variables (proxy)
|
||||
m_searchProcess->setEnvironment(QProcess::systemEnvironment());
|
||||
m_searchProcess->setProcessEnvironment(m_manager->proxyEnvironment());
|
||||
m_searchProcess->setProgram(Utils::ForeignApps::pythonInfo().executableName);
|
||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
m_searchProcess->setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||
#endif
|
||||
|
||||
const QStringList params
|
||||
{
|
||||
|
@ -79,9 +83,6 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
|
|||
m_usedPlugins.join(u','),
|
||||
m_category
|
||||
};
|
||||
|
||||
// Launch search
|
||||
m_searchProcess->setProgram(Utils::ForeignApps::pythonInfo().executableName);
|
||||
m_searchProcess->setArguments(params + m_pattern.split(u' '));
|
||||
|
||||
connect(m_searchProcess, &QProcess::errorOccurred, this, &SearchHandler::processFailed);
|
||||
|
@ -93,6 +94,7 @@ SearchHandler::SearchHandler(const QString &pattern, const QString &category, co
|
|||
connect(m_searchTimeout, &QTimer::timeout, this, &SearchHandler::cancelSearch);
|
||||
m_searchTimeout->start(3min);
|
||||
|
||||
// Launch search
|
||||
// deferred start allows clients to handle starting-related signals
|
||||
QMetaObject::invokeMethod(this, [this]() { m_searchProcess->start(QIODevice::ReadOnly); }
|
||||
, Qt::QueuedConnection);
|
||||
|
|
|
@ -88,6 +88,7 @@ QPointer<SearchPluginManager> SearchPluginManager::m_instance = nullptr;
|
|||
|
||||
SearchPluginManager::SearchPluginManager()
|
||||
: m_updateUrl(u"https://searchplugins.qbittorrent.org/nova3/engines/"_s)
|
||||
, m_proxyEnv {QProcessEnvironment::systemEnvironment()}
|
||||
{
|
||||
Q_ASSERT(!m_instance); // only one instance is allowed
|
||||
m_instance = this;
|
||||
|
@ -359,7 +360,12 @@ SearchHandler *SearchPluginManager::startSearch(const QString &pattern, const QS
|
|||
// No search pattern entered
|
||||
Q_ASSERT(!pattern.isEmpty());
|
||||
|
||||
return new SearchHandler {pattern, category, usedPlugins, this};
|
||||
return new SearchHandler(pattern, category, usedPlugins, this);
|
||||
}
|
||||
|
||||
QProcessEnvironment SearchPluginManager::proxyEnvironment() const
|
||||
{
|
||||
return m_proxyEnv;
|
||||
}
|
||||
|
||||
QString SearchPluginManager::categoryFullName(const QString &categoryName)
|
||||
|
@ -403,50 +409,70 @@ Path SearchPluginManager::engineLocation()
|
|||
|
||||
void SearchPluginManager::applyProxySettings()
|
||||
{
|
||||
const auto *proxyManager = Net::ProxyConfigurationManager::instance();
|
||||
const Net::ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
|
||||
// for python `urllib`: https://docs.python.org/3/library/urllib.request.html#urllib.request.ProxyHandler
|
||||
const QString HTTP_PROXY = u"http_proxy"_s;
|
||||
const QString HTTPS_PROXY = u"https_proxy"_s;
|
||||
// for `helpers.setupSOCKSProxy()`: https://everything.curl.dev/usingcurl/proxies/socks.html
|
||||
const QString SOCKS_PROXY = u"qbt_socks_proxy"_s;
|
||||
|
||||
// Define environment variables for urllib in search engine plugins
|
||||
QString proxyStrHTTP, proxyStrSOCK;
|
||||
if ((proxyConfig.type != Net::ProxyType::None) && Preferences::instance()->useProxyForGeneralPurposes())
|
||||
if (!Preferences::instance()->useProxyForGeneralPurposes())
|
||||
{
|
||||
switch (proxyConfig.type)
|
||||
{
|
||||
case Net::ProxyType::HTTP:
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
proxyStrHTTP = u"http://%1:%2@%3:%4"_s.arg(proxyConfig.username
|
||||
, proxyConfig.password, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyStrHTTP = u"http://%1:%2"_s.arg(proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
break;
|
||||
|
||||
case Net::ProxyType::SOCKS5:
|
||||
if (proxyConfig.authEnabled)
|
||||
{
|
||||
proxyStrSOCK = u"%1:%2@%3:%4"_s.arg(proxyConfig.username
|
||||
, proxyConfig.password, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyStrSOCK = u"%1:%2"_s.arg(proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
qDebug("Disabling HTTP communications proxy");
|
||||
}
|
||||
|
||||
qDebug("HTTP communications proxy string: %s"
|
||||
, qUtf8Printable((proxyConfig.type == Net::ProxyType::SOCKS5) ? proxyStrSOCK : proxyStrHTTP));
|
||||
m_proxyEnv.remove(HTTP_PROXY);
|
||||
m_proxyEnv.remove(HTTPS_PROXY);
|
||||
m_proxyEnv.remove(SOCKS_PROXY);
|
||||
return;
|
||||
}
|
||||
|
||||
qputenv("http_proxy", proxyStrHTTP.toLocal8Bit());
|
||||
qputenv("https_proxy", proxyStrHTTP.toLocal8Bit());
|
||||
qputenv("sock_proxy", proxyStrSOCK.toLocal8Bit());
|
||||
const Net::ProxyConfiguration proxyConfig = Net::ProxyConfigurationManager::instance()->proxyConfiguration();
|
||||
switch (proxyConfig.type)
|
||||
{
|
||||
case Net::ProxyType::None:
|
||||
m_proxyEnv.remove(HTTP_PROXY);
|
||||
m_proxyEnv.remove(HTTPS_PROXY);
|
||||
m_proxyEnv.remove(SOCKS_PROXY);
|
||||
break;
|
||||
|
||||
case Net::ProxyType::HTTP:
|
||||
{
|
||||
const QString credential = proxyConfig.authEnabled
|
||||
? (proxyConfig.username + u':' + proxyConfig.password + u'@')
|
||||
: QString();
|
||||
const QString proxyURL = u"http://%1%2:%3"_s
|
||||
.arg(credential, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
|
||||
m_proxyEnv.insert(HTTP_PROXY, proxyURL);
|
||||
m_proxyEnv.insert(HTTPS_PROXY, proxyURL);
|
||||
m_proxyEnv.remove(SOCKS_PROXY);
|
||||
}
|
||||
break;
|
||||
|
||||
case Net::ProxyType::SOCKS5:
|
||||
{
|
||||
const QString scheme = proxyConfig.hostnameLookupEnabled ? u"socks5h"_s : u"socks5"_s;
|
||||
const QString credential = proxyConfig.authEnabled
|
||||
? (proxyConfig.username + u':' + proxyConfig.password + u'@')
|
||||
: QString();
|
||||
const QString proxyURL = u"%1://%2%3:%4"_s
|
||||
.arg(scheme, credential, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
|
||||
m_proxyEnv.remove(HTTP_PROXY);
|
||||
m_proxyEnv.remove(HTTPS_PROXY);
|
||||
m_proxyEnv.insert(SOCKS_PROXY, proxyURL);
|
||||
}
|
||||
break;
|
||||
|
||||
case Net::ProxyType::SOCKS4:
|
||||
{
|
||||
const QString scheme = proxyConfig.hostnameLookupEnabled ? u"socks4a"_s : u"socks4"_s;
|
||||
const QString proxyURL = u"%1://%2:%3"_s
|
||||
.arg(scheme, proxyConfig.ip, QString::number(proxyConfig.port));
|
||||
|
||||
m_proxyEnv.remove(HTTP_PROXY);
|
||||
m_proxyEnv.remove(HTTPS_PROXY);
|
||||
m_proxyEnv.insert(SOCKS_PROXY, proxyURL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchPluginManager::versionInfoDownloadFinished(const Net::DownloadResult &result)
|
||||
|
@ -469,9 +495,9 @@ void SearchPluginManager::pluginDownloadFinished(const Net::DownloadResult &resu
|
|||
}
|
||||
else
|
||||
{
|
||||
const QString url = result.url;
|
||||
QString pluginName = url.mid(url.lastIndexOf(u'/') + 1);
|
||||
pluginName.replace(u".py"_s, u""_s, Qt::CaseInsensitive);
|
||||
const QString &url = result.url;
|
||||
const QString pluginName = url.sliced(url.lastIndexOf(u'/') + 1)
|
||||
.replace(u".py"_s, u""_s, Qt::CaseInsensitive);
|
||||
|
||||
if (pluginInfo(pluginName))
|
||||
emit pluginUpdateFailed(pluginName, tr("Failed to download the plugin file. %1").arg(result.errorString));
|
||||
|
@ -497,29 +523,32 @@ void SearchPluginManager::updateNova()
|
|||
packageFile2.close();
|
||||
|
||||
// Copy search plugin files (if necessary)
|
||||
const auto updateFile = [&enginePath](const Path &filename, const bool compareVersion)
|
||||
const auto updateFile = [&enginePath](const Path &filename)
|
||||
{
|
||||
const Path filePathBundled = Path(u":/searchengine/nova3"_s) / filename;
|
||||
const Path filePathDisk = enginePath / filename;
|
||||
|
||||
if (compareVersion && (getPluginVersion(filePathBundled) <= getPluginVersion(filePathDisk)))
|
||||
if (getPluginVersion(filePathBundled) <= getPluginVersion(filePathDisk))
|
||||
return;
|
||||
|
||||
Utils::Fs::removeFile(filePathDisk);
|
||||
Utils::Fs::copyFile(filePathBundled, filePathDisk);
|
||||
};
|
||||
|
||||
updateFile(Path(u"helpers.py"_s), true);
|
||||
updateFile(Path(u"nova2.py"_s), true);
|
||||
updateFile(Path(u"nova2dl.py"_s), true);
|
||||
updateFile(Path(u"novaprinter.py"_s), true);
|
||||
updateFile(Path(u"socks.py"_s), false);
|
||||
updateFile(Path(u"helpers.py"_s));
|
||||
updateFile(Path(u"nova2.py"_s));
|
||||
updateFile(Path(u"nova2dl.py"_s));
|
||||
updateFile(Path(u"novaprinter.py"_s));
|
||||
updateFile(Path(u"socks.py"_s));
|
||||
}
|
||||
|
||||
void SearchPluginManager::update()
|
||||
{
|
||||
QProcess nova;
|
||||
nova.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
||||
nova.setProcessEnvironment(proxyEnvironment());
|
||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
nova.setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||
#endif
|
||||
|
||||
const QStringList params
|
||||
{
|
||||
|
@ -592,14 +621,14 @@ void SearchPluginManager::parseVersionInfo(const QByteArray &info)
|
|||
QHash<QString, PluginVersion> updateInfo;
|
||||
int numCorrectData = 0;
|
||||
|
||||
const QList<QByteArrayView> lines = Utils::ByteArray::splitToViews(info, "\n", Qt::SkipEmptyParts);
|
||||
const QList<QByteArrayView> lines = Utils::ByteArray::splitToViews(info, "\n");
|
||||
for (QByteArrayView line : lines)
|
||||
{
|
||||
line = line.trimmed();
|
||||
if (line.isEmpty()) continue;
|
||||
if (line.startsWith('#')) continue;
|
||||
|
||||
const QList<QByteArrayView> list = Utils::ByteArray::splitToViews(line, ":", Qt::SkipEmptyParts);
|
||||
const QList<QByteArrayView> list = Utils::ByteArray::splitToViews(line, ":");
|
||||
if (list.size() != 2) continue;
|
||||
|
||||
const auto pluginName = QString::fromUtf8(list.first().trimmed());
|
||||
|
@ -651,9 +680,10 @@ PluginVersion SearchPluginManager::getPluginVersion(const Path &filePath)
|
|||
while (!pluginFile.atEnd())
|
||||
{
|
||||
const auto line = QString::fromUtf8(pluginFile.readLine(lineMaxLength)).remove(u' ');
|
||||
if (!line.startsWith(u"#VERSION:", Qt::CaseInsensitive)) continue;
|
||||
if (!line.startsWith(u"#VERSION:", Qt::CaseInsensitive))
|
||||
continue;
|
||||
|
||||
const QString versionStr = line.mid(9);
|
||||
const QString versionStr = line.sliced(9);
|
||||
const auto version = PluginVersion::fromString(versionStr);
|
||||
if (version.isValid())
|
||||
return version;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <QHash>
|
||||
#include <QMetaType>
|
||||
#include <QObject>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
#include "base/path.h"
|
||||
#include "base/utils/version.h"
|
||||
|
@ -87,6 +88,8 @@ public:
|
|||
SearchHandler *startSearch(const QString &pattern, const QString &category, const QStringList &usedPlugins);
|
||||
SearchDownloadHandler *downloadTorrent(const QString &pluginName, const QString &url);
|
||||
|
||||
QProcessEnvironment proxyEnvironment() const;
|
||||
|
||||
static PluginVersion getPluginVersion(const Path &filePath);
|
||||
static QString categoryFullName(const QString &categoryName);
|
||||
QString pluginFullName(const QString &pluginName) const;
|
||||
|
@ -122,4 +125,5 @@ private:
|
|||
const QString m_updateUrl;
|
||||
|
||||
QHash<QString, PluginInfo*> m_plugins;
|
||||
QProcessEnvironment m_proxyEnv;
|
||||
};
|
||||
|
|
|
@ -170,7 +170,7 @@ bool SettingsStorage::writeNativeSettings() const
|
|||
// between deleting the file and recreating it. This is a safety measure.
|
||||
// Write everything to qBittorrent_new.ini/qBittorrent_new.conf and if it succeeds
|
||||
// replace qBittorrent.ini/qBittorrent.conf with it.
|
||||
for (auto i = m_data.begin(); i != m_data.end(); ++i)
|
||||
for (auto i = m_data.cbegin(); i != m_data.cend(); ++i)
|
||||
nativeSettings->setValue(i.key(), i.value());
|
||||
|
||||
nativeSettings->sync(); // Important to get error status
|
||||
|
|
|
@ -30,28 +30,30 @@
|
|||
#include "bytearray.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QByteArrayMatcher>
|
||||
#include <QByteArrayView>
|
||||
#include <QList>
|
||||
|
||||
QList<QByteArrayView> Utils::ByteArray::splitToViews(const QByteArrayView in, const QByteArrayView sep, const Qt::SplitBehavior behavior)
|
||||
QList<QByteArrayView> Utils::ByteArray::splitToViews(const QByteArrayView in, const QByteArrayView sep)
|
||||
{
|
||||
if (in.isEmpty())
|
||||
return {};
|
||||
if (sep.isEmpty())
|
||||
return {in};
|
||||
|
||||
const QByteArrayMatcher matcher {sep};
|
||||
QList<QByteArrayView> ret;
|
||||
ret.reserve((behavior == Qt::KeepEmptyParts)
|
||||
? (1 + (in.size() / sep.size()))
|
||||
: (1 + (in.size() / (sep.size() + 1))));
|
||||
int head = 0;
|
||||
ret.reserve(1 + (in.size() / (sep.size() + 1)));
|
||||
qsizetype head = 0;
|
||||
while (head < in.size())
|
||||
{
|
||||
int end = in.indexOf(sep, head);
|
||||
qsizetype end = matcher.indexIn(in, head);
|
||||
if (end < 0)
|
||||
end = in.size();
|
||||
|
||||
// omit empty parts
|
||||
const QByteArrayView part = in.mid(head, (end - head));
|
||||
if (!part.isEmpty() || (behavior == Qt::KeepEmptyParts))
|
||||
const QByteArrayView part = in.sliced(head, (end - head));
|
||||
if (!part.isEmpty())
|
||||
ret += part;
|
||||
|
||||
head = end + sep.size();
|
||||
|
|
|
@ -37,8 +37,8 @@ class QByteArrayView;
|
|||
|
||||
namespace Utils::ByteArray
|
||||
{
|
||||
// Mimic QStringView(in).split(sep, behavior)
|
||||
QList<QByteArrayView> splitToViews(QByteArrayView in, QByteArrayView sep, Qt::SplitBehavior behavior = Qt::KeepEmptyParts);
|
||||
// Inspired by QStringView(in).split(sep, Qt::SkipEmptyParts)
|
||||
QList<QByteArrayView> splitToViews(QByteArrayView in, QByteArrayView sep);
|
||||
QByteArray asQByteArray(QByteArrayView view);
|
||||
|
||||
QByteArray toBase32(const QByteArray &in);
|
||||
|
|
|
@ -64,7 +64,7 @@ int Utils::Compare::naturalCompare(const QString &left, const QString &right, co
|
|||
const int start = pos;
|
||||
while ((pos < str.size()) && str[pos].isDigit())
|
||||
++pos;
|
||||
return str.mid(start, (pos - start));
|
||||
return str.sliced(start, (pos - start));
|
||||
};
|
||||
|
||||
const QStringView numViewL = numberView(left, posL);
|
||||
|
|
|
@ -57,6 +57,9 @@ namespace
|
|||
info = {};
|
||||
|
||||
QProcess proc;
|
||||
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(6, 6, 0))
|
||||
proc.setUnixProcessParameters(QProcess::UnixProcessFlag::CloseFileDescriptors);
|
||||
#endif
|
||||
proc.start(exeName, {u"--version"_s}, QIODevice::ReadOnly);
|
||||
if (proc.waitForFinished() && (proc.exitCode() == QProcess::NormalExit))
|
||||
{
|
||||
|
@ -68,7 +71,7 @@ namespace
|
|||
// Software 'Anaconda' installs its own python interpreter
|
||||
// and `python --version` returns a string like this:
|
||||
// "Python 3.4.3 :: Anaconda 2.3.0 (64-bit)"
|
||||
const QList<QByteArrayView> outputSplit = Utils::ByteArray::splitToViews(procOutput, " ", Qt::SkipEmptyParts);
|
||||
const QList<QByteArrayView> outputSplit = Utils::ByteArray::splitToViews(procOutput, " ");
|
||||
if (outputSplit.size() <= 1)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -316,7 +316,11 @@ bool Utils::OS::applyMarkOfTheWeb(const Path &file, const QString &url)
|
|||
|
||||
::CFDictionarySetValue(properties, kLSQuarantineTypeKey, kLSQuarantineTypeOtherDownload);
|
||||
if (!url.isEmpty())
|
||||
::CFDictionarySetValue(properties, kLSQuarantineDataURLKey, url.toCFString());
|
||||
{
|
||||
const CFStringRef urlCFString = url.toCFString();
|
||||
[[maybe_unused]] const auto urlStringGuard = qScopeGuard([&urlCFString] { ::CFRelease(urlCFString); });
|
||||
::CFDictionarySetValue(properties, kLSQuarantineDataURLKey, urlCFString);
|
||||
}
|
||||
|
||||
const Boolean success = ::CFURLSetResourcePropertyForKey(fileURL, kCFURLQuarantinePropertiesKey
|
||||
, properties, NULL);
|
||||
|
|
|
@ -115,7 +115,7 @@ bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QString &pa
|
|||
|
||||
bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QByteArray &password)
|
||||
{
|
||||
const QList<QByteArrayView> list = ByteArray::splitToViews(secret, ":", Qt::SkipEmptyParts);
|
||||
const QList<QByteArrayView> list = ByteArray::splitToViews(secret, ":");
|
||||
if (list.size() != 2)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -49,12 +49,13 @@ namespace Utils::String
|
|||
template <typename T>
|
||||
T unquote(const T &str, const QString "es = u"\""_s)
|
||||
{
|
||||
if (str.length() < 2) return str;
|
||||
if (str.length() < 2)
|
||||
return str;
|
||||
|
||||
for (const QChar quote : quotes)
|
||||
{
|
||||
if (str.startsWith(quote) && str.endsWith(quote))
|
||||
return str.mid(1, (str.length() - 2));
|
||||
return str.sliced(1, (str.length() - 2));
|
||||
}
|
||||
|
||||
return str;
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
#pragma once
|
||||
|
||||
#define QBT_VERSION_MAJOR 5
|
||||
#define QBT_VERSION_MINOR 1
|
||||
#define QBT_VERSION_MINOR 2
|
||||
#define QBT_VERSION_BUGFIX 0
|
||||
#define QBT_VERSION_BUILD 0
|
||||
#define QBT_VERSION_STATUS "beta1" // Should be empty for stable releases!
|
||||
#define QBT_VERSION_STATUS "alpha1" // Should be empty for stable releases!
|
||||
|
||||
#define QBT__STRINGIFY(x) #x
|
||||
#define QBT_STRINGIFY(x) QBT__STRINGIFY(x)
|
||||
|
|
|
@ -18,6 +18,7 @@ qt_wrap_ui(UI_HEADERS
|
|||
properties/peersadditiondialog.ui
|
||||
properties/propertieswidget.ui
|
||||
rss/automatedrssdownloader.ui
|
||||
rss/rssfeeddialog.ui
|
||||
rss/rsswidget.ui
|
||||
search/pluginselectdialog.ui
|
||||
search/pluginsourcedialog.ui
|
||||
|
@ -69,6 +70,7 @@ add_library(qbt_gui STATIC
|
|||
log/logmodel.h
|
||||
mainwindow.h
|
||||
optionsdialog.h
|
||||
powermanagement/inhibitor.h
|
||||
powermanagement/powermanagement.h
|
||||
previewlistdelegate.h
|
||||
previewselectdialog.h
|
||||
|
@ -88,6 +90,7 @@ add_library(qbt_gui STATIC
|
|||
rss/automatedrssdownloader.h
|
||||
rss/feedlistwidget.h
|
||||
rss/htmlbrowser.h
|
||||
rss/rssfeeddialog.h
|
||||
rss/rsswidget.h
|
||||
search/pluginselectdialog.h
|
||||
search/pluginsourcedialog.h
|
||||
|
@ -137,6 +140,7 @@ add_library(qbt_gui STATIC
|
|||
uithememanager.h
|
||||
uithemesource.h
|
||||
utils.h
|
||||
utils/keysequence.h
|
||||
watchedfolderoptionsdialog.h
|
||||
watchedfoldersmodel.h
|
||||
windowstate.h
|
||||
|
@ -167,6 +171,7 @@ add_library(qbt_gui STATIC
|
|||
log/logmodel.cpp
|
||||
mainwindow.cpp
|
||||
optionsdialog.cpp
|
||||
powermanagement/inhibitor.cpp
|
||||
powermanagement/powermanagement.cpp
|
||||
previewlistdelegate.cpp
|
||||
previewselectdialog.cpp
|
||||
|
@ -186,6 +191,7 @@ add_library(qbt_gui STATIC
|
|||
rss/automatedrssdownloader.cpp
|
||||
rss/feedlistwidget.cpp
|
||||
rss/htmlbrowser.cpp
|
||||
rss/rssfeeddialog.cpp
|
||||
rss/rsswidget.cpp
|
||||
search/pluginselectdialog.cpp
|
||||
search/pluginsourcedialog.cpp
|
||||
|
@ -234,6 +240,7 @@ add_library(qbt_gui STATIC
|
|||
uithememanager.cpp
|
||||
uithemesource.cpp
|
||||
utils.cpp
|
||||
utils/keysequence.cpp
|
||||
watchedfolderoptionsdialog.cpp
|
||||
watchedfoldersmodel.cpp
|
||||
|
||||
|
@ -259,8 +266,8 @@ if (DBUS)
|
|||
notifications/dbusnotifier.cpp
|
||||
notifications/dbusnotificationsinterface.h
|
||||
notifications/dbusnotificationsinterface.cpp
|
||||
powermanagement/powermanagement_x11.h
|
||||
powermanagement/powermanagement_x11.cpp
|
||||
powermanagement/inhibitordbus.h
|
||||
powermanagement/inhibitordbus.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -274,21 +281,29 @@ if (STACKTRACE)
|
|||
)
|
||||
endif()
|
||||
|
||||
if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
|
||||
target_sources(qbt_gui PRIVATE
|
||||
programupdater.h
|
||||
programupdater.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
target_sources(qbt_gui PRIVATE
|
||||
macosdockbadge/badger.h
|
||||
macosdockbadge/badger.mm
|
||||
macosdockbadge/badgeview.h
|
||||
macosdockbadge/badgeview.mm
|
||||
macosshiftclickhandler.h
|
||||
macosshiftclickhandler.cpp
|
||||
macutilities.h
|
||||
macutilities.mm
|
||||
powermanagement/inhibitormacos.h
|
||||
powermanagement/inhibitormacos.cpp
|
||||
programupdater.h
|
||||
programupdater.cpp
|
||||
)
|
||||
target_link_libraries(qbt_gui PRIVATE objc)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_sources(qbt_gui PRIVATE
|
||||
powermanagement/inhibitorwindows.h
|
||||
powermanagement/inhibitorwindows.cpp
|
||||
programupdater.h
|
||||
programupdater.cpp
|
||||
)
|
||||
endif()
|
||||
|
|
|
@ -67,7 +67,7 @@ AboutDialog::AboutDialog(QWidget *parent)
|
|||
u"</p>"_s
|
||||
.arg(tr("An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar.")
|
||||
.replace(u"C++"_s, u"C\u2060+\u2060+"_s) // make C++ non-breaking
|
||||
, tr("Copyright %1 2006-2024 The qBittorrent project").arg(C_COPYRIGHT)
|
||||
, tr("Copyright %1 2006-2025 The qBittorrent project").arg(C_COPYRIGHT)
|
||||
, tr("Home Page:")
|
||||
, tr("Forum:")
|
||||
, tr("Bug Tracker:"));
|
||||
|
|
|
@ -75,6 +75,9 @@
|
|||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByKeyboard|Qt::TextInteractionFlag::LinksAccessibleByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -90,6 +93,27 @@
|
|||
<string>Current maintainer</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string notr="true">Sledgehammer999</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Nationality:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
|
@ -97,6 +121,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>E-mail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_19">
|
||||
<property name="text">
|
||||
|
@ -110,34 +141,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Nationality:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>E-mail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string notr="true">Sledgehammer999</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -160,10 +163,10 @@
|
|||
<string>Original author</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>France</string>
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -174,6 +177,27 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Nationality:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>France</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>E-mail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
|
@ -187,27 +211,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>E-mail:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Nationality:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -365,8 +368,54 @@
|
|||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="labelBoostVer">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelQt">
|
||||
<property name="text">
|
||||
<string notr="true">Qt:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="labelQtVer">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelLibt">
|
||||
<property name="text">
|
||||
<string notr="true">Libtorrent:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="labelLibtVer">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
|
@ -385,32 +434,6 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelQt">
|
||||
<property name="text">
|
||||
<string notr="true">Qt:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelLibt">
|
||||
<property name="text">
|
||||
<string notr="true">Libtorrent:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="labelBoost">
|
||||
<property name="text">
|
||||
|
@ -424,33 +447,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="labelQtVer">
|
||||
<item row="2" column="2">
|
||||
<widget class="QLabel" name="labelBoostVer">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="labelLibtVer">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::LinksAccessibleByMouse|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="labelOpenssl">
|
||||
<property name="text">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2022-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2022-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -122,7 +122,7 @@ namespace
|
|||
fsPathEdit->setCurrentIndex(existingIndex);
|
||||
}
|
||||
|
||||
void updatePathHistory(const QString &settingsKey, const Path &path, const int maxLength)
|
||||
void updatePathHistory(const QString &settingsKey, const Path &path, const qsizetype maxLength)
|
||||
{
|
||||
// Add last used save path to the front of history
|
||||
|
||||
|
@ -134,7 +134,10 @@ namespace
|
|||
else
|
||||
pathList.prepend(path.toString());
|
||||
|
||||
settings()->storeValue(settingsKey, QStringList(pathList.mid(0, maxLength)));
|
||||
if (pathList.size() > maxLength)
|
||||
pathList.resize(maxLength);
|
||||
|
||||
settings()->storeValue(settingsKey, pathList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -375,8 +378,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to
|
|||
connect(Preferences::instance(), &Preferences::changed, []
|
||||
{
|
||||
const int length = Preferences::instance()->addNewTorrentDialogSavePathHistoryLength();
|
||||
settings()->storeValue(KEY_SAVEPATHHISTORY
|
||||
, QStringList(settings()->loadValue<QStringList>(KEY_SAVEPATHHISTORY).mid(0, length)));
|
||||
settings()->storeValue(KEY_SAVEPATHHISTORY, settings()->loadValue<QStringList>(KEY_SAVEPATHHISTORY).mid(0, length));
|
||||
});
|
||||
|
||||
setCurrentContext(std::make_shared<Context>(Context {torrentDescr, inParams}));
|
||||
|
@ -384,7 +386,6 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to
|
|||
|
||||
AddNewTorrentDialog::~AddNewTorrentDialog()
|
||||
{
|
||||
saveState();
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
@ -398,7 +399,7 @@ void AddNewTorrentDialog::loadState()
|
|||
if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
|
||||
resize(dialogSize);
|
||||
|
||||
m_ui->splitter->restoreState(m_storeSplitterState);;
|
||||
m_ui->splitter->restoreState(m_storeSplitterState);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::saveState()
|
||||
|
@ -834,6 +835,12 @@ void AddNewTorrentDialog::reject()
|
|||
QDialog::reject();
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::done(const int result)
|
||||
{
|
||||
saveState();
|
||||
QDialog::done(result);
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &metadata)
|
||||
{
|
||||
Q_ASSERT(m_currentContext);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2022-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2022-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2012 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -68,6 +68,11 @@ signals:
|
|||
void torrentAccepted(const BitTorrent::TorrentDescriptor &torrentDescriptor, const BitTorrent::AddTorrentParams &addTorrentParams);
|
||||
void torrentRejected(const BitTorrent::TorrentDescriptor &torrentDescriptor);
|
||||
|
||||
public slots:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
void done(int result) override;
|
||||
|
||||
private slots:
|
||||
void updateDiskSpaceLabel();
|
||||
void onSavePathChanged(const Path &newPath);
|
||||
|
@ -77,9 +82,6 @@ private slots:
|
|||
void categoryChanged(int index);
|
||||
void contentLayoutChanged();
|
||||
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
|
||||
private:
|
||||
class TorrentContentAdaptor;
|
||||
struct Context;
|
||||
|
|
|
@ -378,6 +378,26 @@
|
|||
<string>Torrent information</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelSize">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelSizeData"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelDate">
|
||||
<property name="text">
|
||||
<string>Date:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelDateData"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelInfohash1">
|
||||
<property name="text">
|
||||
|
@ -385,11 +405,36 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="labelSizeData"/>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="labelInfohash1Data">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="labelDateData"/>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelInfohash2">
|
||||
<property name="text">
|
||||
<string>Info hash v2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="labelInfohash2Data">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelComment">
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
|
@ -439,7 +484,7 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::TextBrowserInteraction</set>
|
||||
<set>Qt::TextInteractionFlag::TextSelectableByKeyboard|Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -447,51 +492,6 @@
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelComment">
|
||||
<property name="text">
|
||||
<string>Comment:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelSize">
|
||||
<property name="text">
|
||||
<string>Size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="labelInfohash1Data">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelDate">
|
||||
<property name="text">
|
||||
<string>Date:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelInfohash2">
|
||||
<property name="text">
|
||||
<string>Info hash v2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="labelInfohash2Data">
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextInteractionFlag::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include "base/global.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/unicodestrings.h"
|
||||
#include "gui/addnewtorrentdialog.h"
|
||||
#include "gui/desktopintegration.h"
|
||||
#include "gui/mainwindow.h"
|
||||
#include "interfaces/iguiapplication.h"
|
||||
|
@ -99,6 +98,7 @@ namespace
|
|||
ENABLE_SPEED_WIDGET,
|
||||
#ifndef Q_OS_MACOS
|
||||
ENABLE_ICONS_IN_MENUS,
|
||||
USE_ATTACHED_ADD_NEW_TORRENT_DIALOG,
|
||||
#endif
|
||||
// embedded tracker
|
||||
TRACKER_STATUS,
|
||||
|
@ -151,6 +151,7 @@ namespace
|
|||
UPNP_LEASE_DURATION,
|
||||
PEER_TOS,
|
||||
UTP_MIX_MODE,
|
||||
HOSTNAME_CACHE_TTL,
|
||||
IDN_SUPPORT,
|
||||
MULTI_CONNECTIONS_PER_IP,
|
||||
VALIDATE_HTTPS_TRACKER_CERTIFICATE,
|
||||
|
@ -163,6 +164,7 @@ namespace
|
|||
ANNOUNCE_ALL_TRACKERS,
|
||||
ANNOUNCE_ALL_TIERS,
|
||||
ANNOUNCE_IP,
|
||||
ANNOUNCE_PORT,
|
||||
MAX_CONCURRENT_HTTP_ANNOUNCES,
|
||||
STOP_TRACKER_TIMEOUT,
|
||||
PEER_TURNOVER,
|
||||
|
@ -277,6 +279,8 @@ void AdvancedSettings::saveAdvancedSettings() const
|
|||
session->setPeerToS(m_spinBoxPeerToS.value());
|
||||
// uTP-TCP mixed mode
|
||||
session->setUtpMixedMode(m_comboBoxUtpMixedMode.currentData().value<BitTorrent::MixedModeAlgorithm>());
|
||||
// Hostname resolver cache TTL
|
||||
session->setHostnameCacheTTL(m_spinBoxHostnameCacheTTL.value());
|
||||
// Support internationalized domain name (IDN)
|
||||
session->setIDNSupportEnabled(m_checkBoxIDNSupport.isChecked());
|
||||
// multiple connections per IP
|
||||
|
@ -309,6 +313,8 @@ void AdvancedSettings::saveAdvancedSettings() const
|
|||
// Construct a QHostAddress to filter malformed strings
|
||||
const QHostAddress addr(m_lineEditAnnounceIP.text().trimmed());
|
||||
session->setAnnounceIP(addr.toString());
|
||||
// Announce Port
|
||||
session->setAnnouncePort(m_spinBoxAnnouncePort.value());
|
||||
// Max concurrent HTTP announces
|
||||
session->setMaxConcurrentHTTPAnnounces(m_spinBoxMaxConcurrentHTTPAnnounces.value());
|
||||
// Stop tracker timeout
|
||||
|
@ -327,6 +333,7 @@ void AdvancedSettings::saveAdvancedSettings() const
|
|||
pref->setSpeedWidgetEnabled(m_checkBoxSpeedWidgetEnabled.isChecked());
|
||||
#ifndef Q_OS_MACOS
|
||||
pref->setIconsInMenusEnabled(m_checkBoxIconsInMenusEnabled.isChecked());
|
||||
pref->setAddNewTorrentDialogAttached(m_checkBoxAttachedAddNewTorrentDialog.isChecked());
|
||||
#endif
|
||||
|
||||
// Tracker
|
||||
|
@ -729,6 +736,14 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||
addRow(UTP_MIX_MODE, (tr("%1-TCP mixed mode algorithm", "uTP-TCP mixed mode algorithm").arg(C_UTP)
|
||||
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#mixed_mode_algorithm", u"(?)"))
|
||||
, &m_comboBoxUtpMixedMode);
|
||||
// Hostname resolver cache TTL
|
||||
m_spinBoxHostnameCacheTTL.setMinimum(0);
|
||||
m_spinBoxHostnameCacheTTL.setMaximum(std::numeric_limits<int>::max());
|
||||
m_spinBoxHostnameCacheTTL.setValue(session->hostnameCacheTTL());
|
||||
m_spinBoxHostnameCacheTTL.setSuffix(tr(" s", " seconds"));
|
||||
addRow(HOSTNAME_CACHE_TTL, (tr("Internal hostname resolver cache expiry interval")
|
||||
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#resolver_cache_timeout", u"(?)"))
|
||||
, &m_spinBoxHostnameCacheTTL);
|
||||
// Support internationalized domain name (IDN)
|
||||
m_checkBoxIDNSupport.setChecked(session->isIDNSupportEnabled());
|
||||
addRow(IDN_SUPPORT, (tr("Support internationalized domain name (IDN)")
|
||||
|
@ -801,6 +816,13 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||
addRow(ANNOUNCE_IP, (tr("IP address reported to trackers (requires restart)")
|
||||
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_ip", u"(?)"))
|
||||
, &m_lineEditAnnounceIP);
|
||||
// Announce port
|
||||
m_spinBoxAnnouncePort.setMinimum(0);
|
||||
m_spinBoxAnnouncePort.setMaximum(65535);
|
||||
m_spinBoxAnnouncePort.setValue(session->announcePort());
|
||||
addRow(ANNOUNCE_PORT, (tr("Port reported to trackers (requires restart) [0: listening port]")
|
||||
+ u' ' + makeLink(u"https://www.libtorrent.org/reference-Settings.html#announce_port", u"(?)"))
|
||||
, &m_spinBoxAnnouncePort);
|
||||
// Max concurrent HTTP announces
|
||||
m_spinBoxMaxConcurrentHTTPAnnounces.setMaximum(std::numeric_limits<int>::max());
|
||||
m_spinBoxMaxConcurrentHTTPAnnounces.setValue(session->maxConcurrentHTTPAnnounces());
|
||||
|
@ -846,6 +868,9 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||
// Enable icons in menus
|
||||
m_checkBoxIconsInMenusEnabled.setChecked(pref->iconsInMenusEnabled());
|
||||
addRow(ENABLE_ICONS_IN_MENUS, tr("Enable icons in menus"), &m_checkBoxIconsInMenusEnabled);
|
||||
|
||||
m_checkBoxAttachedAddNewTorrentDialog.setChecked(pref->isAddNewTorrentDialogAttached());
|
||||
addRow(USE_ATTACHED_ADD_NEW_TORRENT_DIALOG, tr("Attach \"Add new torrent\" dialog to main window"), &m_checkBoxAttachedAddNewTorrentDialog);
|
||||
#endif
|
||||
// Tracker State
|
||||
m_checkBoxTrackerStatus.setChecked(session->isTrackerEnabled());
|
||||
|
|
|
@ -70,10 +70,10 @@ private:
|
|||
|
||||
QSpinBox m_spinBoxSaveResumeDataInterval, m_spinBoxSaveStatisticsInterval, m_spinBoxTorrentFileSizeLimit, m_spinBoxBdecodeDepthLimit, m_spinBoxBdecodeTokenLimit,
|
||||
m_spinBoxAsyncIOThreads, m_spinBoxFilePoolSize, m_spinBoxCheckingMemUsage, m_spinBoxDiskQueueSize,
|
||||
m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxPeerToS,
|
||||
m_spinBoxOutgoingPortsMin, m_spinBoxOutgoingPortsMax, m_spinBoxUPnPLeaseDuration, m_spinBoxPeerToS, m_spinBoxHostnameCacheTTL,
|
||||
m_spinBoxListRefresh, m_spinBoxTrackerPort, m_spinBoxSendBufferWatermark, m_spinBoxSendBufferLowWatermark,
|
||||
m_spinBoxSendBufferWatermarkFactor, m_spinBoxConnectionSpeed, m_spinBoxSocketSendBufferSize, m_spinBoxSocketReceiveBufferSize, m_spinBoxSocketBacklogSize,
|
||||
m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout, m_spinBoxSessionShutdownTimeout,
|
||||
m_spinBoxAnnouncePort, m_spinBoxMaxConcurrentHTTPAnnounces, m_spinBoxStopTrackerTimeout, m_spinBoxSessionShutdownTimeout,
|
||||
m_spinBoxSavePathHistoryLength, m_spinBoxPeerTurnover, m_spinBoxPeerTurnoverCutoff, m_spinBoxPeerTurnoverInterval, m_spinBoxRequestQueueSize;
|
||||
QCheckBox m_checkBoxOsCache, m_checkBoxRecheckCompleted, m_checkBoxResolveCountries, m_checkBoxResolveHosts,
|
||||
m_checkBoxProgramNotifications, m_checkBoxTorrentAddedNotifications, m_checkBoxReannounceWhenAddressChanged, m_checkBoxTrackerFavicon, m_checkBoxTrackerStatus,
|
||||
|
@ -108,6 +108,7 @@ private:
|
|||
|
||||
#ifndef Q_OS_MACOS
|
||||
QCheckBox m_checkBoxIconsInMenusEnabled;
|
||||
QCheckBox m_checkBoxAttachedAddNewTorrentDialog;
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||
|
|
|
@ -102,12 +102,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>bannedIPList</tabstop>
|
||||
<tabstop>txtIP</tabstop>
|
||||
<tabstop>buttonBanIP</tabstop>
|
||||
<tabstop>buttonDeleteIP</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -234,14 +234,14 @@ void FileSystemPathEdit::setFileNameFilter(const QString &val)
|
|||
const int closeBracePos = val.indexOf(u')', (openBracePos + 1));
|
||||
if ((openBracePos > 0) && (closeBracePos > 0) && (closeBracePos > openBracePos + 2))
|
||||
{
|
||||
QString filterString = val.mid(openBracePos + 1, closeBracePos - openBracePos - 1);
|
||||
const QString filterString = val.sliced((openBracePos + 1), (closeBracePos - openBracePos - 1));
|
||||
if (filterString == u"*")
|
||||
{ // no filters
|
||||
d->m_editor->setFilenameFilters({});
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList filters = filterString.split(u' ', Qt::SkipEmptyParts);
|
||||
const QStringList filters = filterString.split(u' ', Qt::SkipEmptyParts);
|
||||
d->m_editor->setFilenameFilters(filters);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/torrentdescriptor.h"
|
||||
#include "base/logger.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/preferences.h"
|
||||
#include "base/torrentfileguard.h"
|
||||
|
@ -82,6 +81,15 @@ GUIAddTorrentManager::GUIAddTorrentManager(IGUIApplication *app, BitTorrent::Ses
|
|||
connect(btSession(), &BitTorrent::Session::metadataDownloaded, this, &GUIAddTorrentManager::onMetadataDownloaded);
|
||||
}
|
||||
|
||||
GUIAddTorrentManager::~GUIAddTorrentManager()
|
||||
{
|
||||
for (AddNewTorrentDialog *dialog : asConst(m_dialogs))
|
||||
{
|
||||
dialog->disconnect(this);
|
||||
dialog->reject();
|
||||
}
|
||||
}
|
||||
|
||||
bool GUIAddTorrentManager::addTorrent(const QString &source, const BitTorrent::AddTorrentParams ¶ms, const AddTorrentOption option)
|
||||
{
|
||||
// `source`: .torrent file path, magnet URI or URL
|
||||
|
@ -225,12 +233,19 @@ bool GUIAddTorrentManager::processTorrent(const QString &source
|
|||
if (!hasMetadata)
|
||||
btSession()->downloadMetadata(torrentDescr);
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
const bool attached = false;
|
||||
#else
|
||||
const bool attached = Preferences::instance()->isAddNewTorrentDialogAttached();
|
||||
#endif
|
||||
|
||||
// By not setting a parent to the "AddNewTorrentDialog", all those dialogs
|
||||
// will be displayed on top and will not overlap with the main window.
|
||||
auto *dlg = new AddNewTorrentDialog(torrentDescr, params, nullptr);
|
||||
auto *dlg = new AddNewTorrentDialog(torrentDescr, params, (attached ? app()->mainWindow() : nullptr));
|
||||
// Qt::Window is required to avoid showing only two dialog on top (see #12852).
|
||||
// Also improves the general convenience of adding multiple torrents.
|
||||
dlg->setWindowFlags(Qt::Window);
|
||||
if (!attached)
|
||||
dlg->setWindowFlags(Qt::Window);
|
||||
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_dialogs[infoHash] = dlg;
|
||||
|
|
|
@ -61,6 +61,7 @@ class GUIAddTorrentManager : public GUIApplicationComponent<AddTorrentManager>
|
|||
|
||||
public:
|
||||
GUIAddTorrentManager(IGUIApplication *app, BitTorrent::Session *session, QObject *parent = nullptr);
|
||||
~GUIAddTorrentManager() override;
|
||||
|
||||
bool addTorrent(const QString &source, const BitTorrent::AddTorrentParams ¶ms = {}, AddTorrentOption option = AddTorrentOption::Default);
|
||||
|
||||
|
|
|
@ -86,12 +86,6 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>whitelistedIPSubnetList</tabstop>
|
||||
<tabstop>txtIPSubnet</tabstop>
|
||||
<tabstop>buttonWhitelistIPSubnet</tabstop>
|
||||
<tabstop>buttonDeleteIPSubnet</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
73
src/gui/macosshiftclickhandler.cpp
Normal file
73
src/gui/macosshiftclickhandler.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Luke Memet (lukemmtt)
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "macosshiftclickhandler.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QTreeView>
|
||||
|
||||
MacOSShiftClickHandler::MacOSShiftClickHandler(QTreeView *treeView)
|
||||
: QObject(treeView)
|
||||
, m_treeView {treeView}
|
||||
{
|
||||
treeView->installEventFilter(this);
|
||||
}
|
||||
|
||||
bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if ((watched == m_treeView) && (event->type() == QEvent::MouseButtonPress))
|
||||
{
|
||||
const auto *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() != Qt::LeftButton)
|
||||
return false;
|
||||
|
||||
const QModelIndex clickedIndex = m_treeView->indexAt(mouseEvent->position().toPoint());
|
||||
if (!clickedIndex.isValid())
|
||||
return false;
|
||||
|
||||
const Qt::KeyboardModifiers modifiers = mouseEvent->modifiers();
|
||||
const bool shiftPressed = modifiers.testFlag(Qt::ShiftModifier);
|
||||
|
||||
if (shiftPressed && m_lastClickedIndex.isValid())
|
||||
{
|
||||
const QItemSelection selection(m_lastClickedIndex, clickedIndex);
|
||||
const bool commandPressed = modifiers.testFlag(Qt::ControlModifier);
|
||||
if (commandPressed)
|
||||
m_treeView->selectionModel()->select(selection, (QItemSelectionModel::Select | QItemSelectionModel::Rows));
|
||||
else
|
||||
m_treeView->selectionModel()->select(selection, (QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows));
|
||||
m_treeView->selectionModel()->setCurrentIndex(clickedIndex, QItemSelectionModel::NoUpdate);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!modifiers.testFlags(Qt::AltModifier | Qt::MetaModifier))
|
||||
m_lastClickedIndex = clickedIndex;
|
||||
}
|
||||
|
||||
return QObject::eventFilter(watched, event);
|
||||
}
|
50
src/gui/macosshiftclickhandler.h
Normal file
50
src/gui/macosshiftclickhandler.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Luke Memet (lukemmtt)
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QPersistentModelIndex>
|
||||
|
||||
class QTreeView;
|
||||
|
||||
// Workaround for QTBUG-115838: Shift-click range selection not working properly on macOS
|
||||
class MacOSShiftClickHandler final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(MacOSShiftClickHandler)
|
||||
|
||||
public:
|
||||
explicit MacOSShiftClickHandler(QTreeView *treeView);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
QTreeView *m_treeView = nullptr;
|
||||
QPersistentModelIndex m_lastClickedIndex;
|
||||
};
|
|
@ -101,6 +101,7 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include "uithememanager.h"
|
||||
#include "utils.h"
|
||||
#include "utils/keysequence.h"
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
#include "macosdockbadge/badger.h"
|
||||
|
@ -130,6 +131,8 @@ MainWindow::MainWindow(IGUIApplication *app, const WindowState initialState, con
|
|||
, m_ui {new Ui::MainWindow}
|
||||
, m_downloadRate {Utils::Misc::friendlyUnit(0, true)}
|
||||
, m_uploadRate {Utils::Misc::friendlyUnit(0, true)}
|
||||
, m_pwr {new PowerManagement}
|
||||
, m_preventTimer {new QTimer(this)}
|
||||
, m_storeExecutionLogEnabled {EXECUTIONLOG_SETTINGS_KEY(u"Enabled"_s)}
|
||||
, m_storeDownloadTrackerFavicon {SETTINGS_KEY(u"DownloadTrackerFavicon"_s)}
|
||||
, m_storeExecutionLogTypes {EXECUTIONLOG_SETTINGS_KEY(u"Types"_s), Log::MsgType::ALL}
|
||||
|
@ -336,8 +339,6 @@ MainWindow::MainWindow(IGUIApplication *app, const WindowState initialState, con
|
|||
connect(m_ui->actionManageCookies, &QAction::triggered, this, &MainWindow::manageCookies);
|
||||
|
||||
// Initialise system sleep inhibition timer
|
||||
m_pwr = new PowerManagement(this);
|
||||
m_preventTimer = new QTimer(this);
|
||||
m_preventTimer->setSingleShot(true);
|
||||
connect(m_preventTimer, &QTimer::timeout, this, &MainWindow::updatePowerManagementState);
|
||||
connect(pref, &Preferences::changed, this, &MainWindow::updatePowerManagementState);
|
||||
|
@ -739,7 +740,7 @@ void MainWindow::displaySearchTab(bool enable)
|
|||
if (!m_searchWidget)
|
||||
{
|
||||
m_searchWidget = new SearchWidget(app(), this);
|
||||
connect(m_searchWidget, &SearchWidget::activeSearchFinished, this, [this](const bool failed)
|
||||
connect(m_searchWidget, &SearchWidget::searchFinished, this, [this](const bool failed)
|
||||
{
|
||||
if (app()->desktopIntegration()->isNotificationsEnabled() && (currentTabWidget() != m_searchWidget))
|
||||
{
|
||||
|
@ -837,6 +838,7 @@ void MainWindow::cleanup()
|
|||
delete m_executableWatcher;
|
||||
|
||||
m_preventTimer->stop();
|
||||
delete m_pwr;
|
||||
|
||||
#if (defined(Q_OS_WIN) || defined(Q_OS_MACOS))
|
||||
if (m_programUpdateTimer)
|
||||
|
@ -882,7 +884,7 @@ void MainWindow::createKeyboardShortcuts()
|
|||
{
|
||||
m_ui->actionCreateTorrent->setShortcut(QKeySequence::New);
|
||||
m_ui->actionOpen->setShortcut(QKeySequence::Open);
|
||||
m_ui->actionDelete->setShortcut(QKeySequence::Delete);
|
||||
m_ui->actionDelete->setShortcut(Utils::KeySequence::deleteItem());
|
||||
m_ui->actionDelete->setShortcutContext(Qt::WidgetShortcut); // nullify its effect: delete key event is handled by respective widgets, not here
|
||||
m_ui->actionDownloadFromURL->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_O);
|
||||
m_ui->actionExit->setShortcut(Qt::CTRL | Qt::Key_Q);
|
||||
|
@ -1826,7 +1828,7 @@ void MainWindow::updatePowerManagementState() const
|
|||
|
||||
return torrent->isMoving();
|
||||
});
|
||||
m_pwr->setActivityState(inhibitSuspend);
|
||||
m_pwr->setActivityState(inhibitSuspend ? PowerManagement::ActivityState::Busy : PowerManagement::ActivityState::Idle);
|
||||
|
||||
m_preventTimer->start(PREVENT_SUSPEND_INTERVAL);
|
||||
}
|
||||
|
|
|
@ -149,8 +149,8 @@
|
|||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDownloadFromURL"/>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="actionDownloadFromURL"/>
|
||||
<addaction name="actionDelete"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionStart"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2023-2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2023-2025 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2024 Jonathan Ketchker
|
||||
* Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
|
||||
*
|
||||
|
@ -53,6 +53,7 @@
|
|||
#include "base/bittorrent/sharelimitaction.h"
|
||||
#include "base/exceptions.h"
|
||||
#include "base/global.h"
|
||||
#include "base/net/downloadmanager.h"
|
||||
#include "base/net/portforwarder.h"
|
||||
#include "base/net/proxyconfigurationmanager.h"
|
||||
#include "base/path.h"
|
||||
|
@ -163,6 +164,7 @@ OptionsDialog::OptionsDialog(IGUIApplication *app, QWidget *parent)
|
|||
m_ui->tabSelection->item(TAB_DOWNLOADS)->setIcon(UIThemeManager::instance()->getIcon(u"download"_s, u"folder-download"_s));
|
||||
m_ui->tabSelection->item(TAB_SPEED)->setIcon(UIThemeManager::instance()->getIcon(u"speedometer"_s, u"chronometer"_s));
|
||||
m_ui->tabSelection->item(TAB_RSS)->setIcon(UIThemeManager::instance()->getIcon(u"application-rss"_s, u"application-rss+xml"_s));
|
||||
m_ui->tabSelection->item(TAB_SEARCH)->setIcon(UIThemeManager::instance()->getIcon(u"edit-find"_s));
|
||||
#ifdef DISABLE_WEBUI
|
||||
m_ui->tabSelection->item(TAB_WEBUI)->setHidden(true);
|
||||
#else
|
||||
|
@ -189,6 +191,7 @@ OptionsDialog::OptionsDialog(IGUIApplication *app, QWidget *parent)
|
|||
loadSpeedTabOptions();
|
||||
loadBittorrentTabOptions();
|
||||
loadRSSTabOptions();
|
||||
loadSearchTabOptions();
|
||||
#ifndef DISABLE_WEBUI
|
||||
loadWebUITabOptions();
|
||||
#endif
|
||||
|
@ -352,6 +355,7 @@ void OptionsDialog::loadBehaviorTabOptions()
|
|||
// Groupbox's check state must be initialized after some of its children if they are manually enabled/disabled
|
||||
m_ui->checkFileLog->setChecked(app()->isFileLoggerEnabled());
|
||||
|
||||
m_ui->checkBoxFreeDiskSpaceStatusBar->setChecked(pref->isStatusbarFreeDiskSpaceDisplayed());
|
||||
m_ui->checkBoxExternalIPStatusBar->setChecked(pref->isStatusbarExternalIPDisplayed());
|
||||
m_ui->checkBoxPerformanceWarning->setChecked(session->isPerformanceWarningEnabled());
|
||||
|
||||
|
@ -440,6 +444,7 @@ void OptionsDialog::loadBehaviorTabOptions()
|
|||
connect(m_ui->spinFileLogAge, qSpinBoxValueChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->comboFileLogAgeType, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
connect(m_ui->checkBoxFreeDiskSpaceStatusBar, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkBoxExternalIPStatusBar, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkBoxPerformanceWarning, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
}
|
||||
|
@ -463,10 +468,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
|
|||
pref->setLocale(locale);
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
if (const QVariant systemStyle = m_ui->comboStyle->currentData(); systemStyle.isValid())
|
||||
pref->setStyle(systemStyle.toString());
|
||||
else
|
||||
pref->setStyle(m_ui->comboStyle->currentText());
|
||||
pref->setStyle(m_ui->comboStyle->currentData().toString());
|
||||
#endif
|
||||
|
||||
#ifdef QBT_HAS_COLORSCHEME_OPTION
|
||||
|
@ -536,6 +538,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
|
|||
|
||||
app()->setStartUpWindowState(m_ui->windowStateComboBox->currentData().value<WindowState>());
|
||||
|
||||
pref->setStatusbarFreeDiskSpaceDisplayed(m_ui->checkBoxFreeDiskSpaceStatusBar->isChecked());
|
||||
pref->setStatusbarExternalIPDisplayed(m_ui->checkBoxExternalIPStatusBar->isChecked());
|
||||
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
|
||||
}
|
||||
|
@ -1151,6 +1154,10 @@ void OptionsDialog::loadBittorrentTabOptions()
|
|||
m_ui->checkEnableAddTrackers->setChecked(session->isAddTrackersEnabled());
|
||||
m_ui->textTrackers->setPlainText(session->additionalTrackers());
|
||||
|
||||
m_ui->checkAddTrackersFromURL->setChecked(session->isAddTrackersFromURLEnabled());
|
||||
m_ui->textTrackersURL->setText(session->additionalTrackersURL());
|
||||
m_ui->textTrackersFromURL->setPlainText(session->additionalTrackersFromURL());
|
||||
|
||||
connect(m_ui->checkDHT, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkPeX, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkLSD, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
|
@ -1184,6 +1191,9 @@ void OptionsDialog::loadBittorrentTabOptions()
|
|||
|
||||
connect(m_ui->checkEnableAddTrackers, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->textTrackers, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
connect(m_ui->checkAddTrackersFromURL, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->textTrackersURL, &QLineEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||
}
|
||||
|
||||
void OptionsDialog::saveBittorrentTabOptions() const
|
||||
|
@ -1221,6 +1231,9 @@ void OptionsDialog::saveBittorrentTabOptions() const
|
|||
|
||||
session->setAddTrackersEnabled(m_ui->checkEnableAddTrackers->isChecked());
|
||||
session->setAdditionalTrackers(m_ui->textTrackers->toPlainText());
|
||||
|
||||
session->setAddTrackersFromURLEnabled(m_ui->checkAddTrackersFromURL->isChecked());
|
||||
session->setAdditionalTrackersURL(m_ui->textTrackersURL->text());
|
||||
}
|
||||
|
||||
void OptionsDialog::loadRSSTabOptions()
|
||||
|
@ -1265,6 +1278,28 @@ void OptionsDialog::saveRSSTabOptions() const
|
|||
autoDownloader->setDownloadRepacks(m_ui->checkSmartFilterDownloadRepacks->isChecked());
|
||||
}
|
||||
|
||||
void OptionsDialog::loadSearchTabOptions()
|
||||
{
|
||||
const auto *pref = Preferences::instance();
|
||||
|
||||
m_ui->groupStoreOpenedTabs->setChecked(pref->storeOpenedSearchTabs());
|
||||
m_ui->checkStoreTabsSearchResults->setChecked(pref->storeOpenedSearchTabResults());
|
||||
m_ui->searchHistoryLengthSpinBox->setValue(pref->searchHistoryLength());
|
||||
|
||||
connect(m_ui->groupStoreOpenedTabs, &QGroupBox::toggled, this, &OptionsDialog::enableApplyButton);
|
||||
connect(m_ui->checkStoreTabsSearchResults, &QCheckBox::toggled, this, &OptionsDialog::enableApplyButton);
|
||||
connect(m_ui->searchHistoryLengthSpinBox, qSpinBoxValueChanged, this, &OptionsDialog::enableApplyButton);
|
||||
}
|
||||
|
||||
void OptionsDialog::saveSearchTabOptions() const
|
||||
{
|
||||
auto *pref = Preferences::instance();
|
||||
|
||||
pref->setStoreOpenedSearchTabs(m_ui->groupStoreOpenedTabs->isChecked());
|
||||
pref->setStoreOpenedSearchTabResults(m_ui->checkStoreTabsSearchResults->isChecked());
|
||||
pref->setSearchHistoryLength(m_ui->searchHistoryLengthSpinBox->value());
|
||||
}
|
||||
|
||||
#ifndef DISABLE_WEBUI
|
||||
void OptionsDialog::loadWebUITabOptions()
|
||||
{
|
||||
|
@ -1457,6 +1492,7 @@ void OptionsDialog::saveOptions() const
|
|||
saveSpeedTabOptions();
|
||||
saveBittorrentTabOptions();
|
||||
saveRSSTabOptions();
|
||||
saveSearchTabOptions();
|
||||
#ifndef DISABLE_WEBUI
|
||||
saveWebUITabOptions();
|
||||
#endif
|
||||
|
@ -1653,7 +1689,7 @@ void OptionsDialog::adjustProxyOptions()
|
|||
|
||||
if (currentProxyType == Net::ProxyType::None)
|
||||
{
|
||||
m_ui->labelProxyTypeIncompatible->setVisible(false);
|
||||
m_ui->labelProxyTypeUnavailable->setVisible(false);
|
||||
|
||||
m_ui->lblProxyIP->setEnabled(false);
|
||||
m_ui->textProxyIP->setEnabled(false);
|
||||
|
@ -1678,7 +1714,7 @@ void OptionsDialog::adjustProxyOptions()
|
|||
|
||||
if (currentProxyType == Net::ProxyType::SOCKS4)
|
||||
{
|
||||
m_ui->labelProxyTypeIncompatible->setVisible(true);
|
||||
m_ui->labelProxyTypeUnavailable->setVisible(true);
|
||||
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(false);
|
||||
m_ui->checkProxyRSS->setEnabled(false);
|
||||
|
@ -1687,7 +1723,7 @@ void OptionsDialog::adjustProxyOptions()
|
|||
else
|
||||
{
|
||||
// SOCKS5 or HTTP
|
||||
m_ui->labelProxyTypeIncompatible->setVisible(false);
|
||||
m_ui->labelProxyTypeUnavailable->setVisible(false);
|
||||
|
||||
m_ui->checkProxyHostnameLookup->setEnabled(true);
|
||||
m_ui->checkProxyRSS->setEnabled(true);
|
||||
|
@ -1705,18 +1741,20 @@ void OptionsDialog::initializeStyleCombo()
|
|||
{
|
||||
#ifdef Q_OS_WIN
|
||||
m_ui->labelStyleHint->setText(tr("%1 is recommended for best compatibility with Windows dark mode"
|
||||
, "Fusion is recommended for best compatibility with Windows dark mode").arg(u"Fusion"_s));
|
||||
, "Fusion is recommended for best compatibility with Windows dark mode").arg(u"Fusion"_s));
|
||||
m_ui->comboStyle->addItem(tr("System", "System default Qt style"), u"system"_s);
|
||||
m_ui->comboStyle->setItemData(0, tr("Let Qt decide the style for this system"), Qt::ToolTipRole);
|
||||
m_ui->comboStyle->insertSeparator(1);
|
||||
|
||||
QStringList styleNames = QStyleFactory::keys();
|
||||
std::sort(styleNames.begin(), styleNames.end(), Utils::Compare::NaturalLessThan<Qt::CaseInsensitive>());
|
||||
m_ui->comboStyle->addItems(styleNames);
|
||||
for (const QString &styleName : asConst(styleNames))
|
||||
m_ui->comboStyle->addItem(styleName, styleName);
|
||||
|
||||
const QString prefStyleName = Preferences::instance()->getStyle();
|
||||
const QString selectedStyleName = prefStyleName.isEmpty() ? QApplication::style()->name() : prefStyleName;
|
||||
m_ui->comboStyle->setCurrentIndex(m_ui->comboStyle->findText(selectedStyleName, Qt::MatchFixedString));
|
||||
const int styleIndex = m_ui->comboStyle->findData(selectedStyleName, Qt::UserRole, Qt::MatchFixedString);
|
||||
m_ui->comboStyle->setCurrentIndex(std::max(0, styleIndex));
|
||||
#else
|
||||
m_ui->labelStyle->hide();
|
||||
m_ui->comboStyle->hide();
|
||||
|
@ -1821,10 +1859,10 @@ void OptionsDialog::setLocale(const QString &localeStr)
|
|||
if (index < 0)
|
||||
{
|
||||
//Attempt to find a language match without a country
|
||||
int pos = name.indexOf(u'_');
|
||||
const int pos = name.indexOf(u'_');
|
||||
if (pos > -1)
|
||||
{
|
||||
QString lang = name.left(pos);
|
||||
const QString lang = name.first(pos);
|
||||
index = m_ui->comboLanguage->findData(lang, Qt::UserRole);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ class OptionsDialog final : public GUIApplicationComponent<QDialog>
|
|||
TAB_CONNECTION,
|
||||
TAB_SPEED,
|
||||
TAB_BITTORRENT,
|
||||
TAB_SEARCH,
|
||||
TAB_RSS,
|
||||
TAB_WEBUI,
|
||||
TAB_ADVANCED
|
||||
|
@ -136,6 +137,9 @@ private:
|
|||
void loadRSSTabOptions();
|
||||
void saveRSSTabOptions() const;
|
||||
|
||||
void loadSearchTabOptions();
|
||||
void saveSearchTabOptions() const;
|
||||
|
||||
#ifndef DISABLE_WEBUI
|
||||
void loadWebUITabOptions();
|
||||
void saveWebUITabOptions() const;
|
||||
|
|
File diff suppressed because it is too large
Load diff
40
src/gui/powermanagement/inhibitor.cpp
Normal file
40
src/gui/powermanagement/inhibitor.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
* Copyright (C) 2011 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "inhibitor.h"
|
||||
|
||||
bool Inhibitor::requestBusy()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Inhibitor::requestIdle()
|
||||
{
|
||||
return true;
|
||||
}
|
38
src/gui/powermanagement/inhibitor.h
Normal file
38
src/gui/powermanagement/inhibitor.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
class Inhibitor
|
||||
{
|
||||
public:
|
||||
virtual ~Inhibitor() = default;
|
||||
|
||||
virtual bool requestBusy();
|
||||
virtual bool requestIdle();
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
* Copyright (C) 2011 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -26,7 +27,7 @@
|
|||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "powermanagement_x11.h"
|
||||
#include "inhibitordbus.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusInterface>
|
||||
|
@ -36,7 +37,7 @@
|
|||
#include "base/global.h"
|
||||
#include "base/logger.h"
|
||||
|
||||
PowerManagementInhibitor::PowerManagementInhibitor(QObject *parent)
|
||||
InhibitorDBus::InhibitorDBus(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_busInterface {new QDBusInterface(u"org.gnome.SessionManager"_s, u"/org/gnome/SessionManager"_s
|
||||
, u"org.gnome.SessionManager"_s, QDBusConnection::sessionBus(), this)}
|
||||
|
@ -70,38 +71,26 @@ PowerManagementInhibitor::PowerManagementInhibitor(QObject *parent)
|
|||
}
|
||||
else
|
||||
{
|
||||
LogMsg(tr("Power management error. Did not found suitable D-Bus interface."), Log::WARNING);
|
||||
m_state = Error;
|
||||
LogMsg(tr("Power management error. Did not find a suitable D-Bus interface."), Log::WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
void PowerManagementInhibitor::requestIdle()
|
||||
{
|
||||
m_intendedState = Idle;
|
||||
if ((m_state == Error) || (m_state == Idle) || (m_state == RequestIdle) || (m_state == RequestBusy))
|
||||
return;
|
||||
|
||||
if (m_manager == ManagerType::Systemd)
|
||||
{
|
||||
m_fd = {};
|
||||
m_state = Idle;
|
||||
return;
|
||||
}
|
||||
|
||||
m_state = RequestIdle;
|
||||
|
||||
const QString method = (m_manager == ManagerType::Gnome)
|
||||
? u"Uninhibit"_s
|
||||
: u"UnInhibit"_s;
|
||||
const QDBusPendingCall pcall = m_busInterface->asyncCall(method, m_cookie);
|
||||
const auto *watcher = new QDBusPendingCallWatcher(pcall, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &PowerManagementInhibitor::onAsyncReply);
|
||||
}
|
||||
|
||||
void PowerManagementInhibitor::requestBusy()
|
||||
bool InhibitorDBus::requestBusy()
|
||||
{
|
||||
m_intendedState = Busy;
|
||||
if ((m_state == Error) || (m_state == Busy) || (m_state == RequestBusy) || (m_state == RequestIdle))
|
||||
return;
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case Busy:
|
||||
case RequestBusy:
|
||||
return true;
|
||||
case Error:
|
||||
case RequestIdle:
|
||||
return false;
|
||||
case Idle:
|
||||
break;
|
||||
};
|
||||
|
||||
m_state = RequestBusy;
|
||||
|
||||
|
@ -123,10 +112,45 @@ void PowerManagementInhibitor::requestBusy()
|
|||
|
||||
const QDBusPendingCall pcall = m_busInterface->asyncCallWithArgumentList(u"Inhibit"_s, args);
|
||||
const auto *watcher = new QDBusPendingCallWatcher(pcall, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &PowerManagementInhibitor::onAsyncReply);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &InhibitorDBus::onAsyncReply);
|
||||
return true;
|
||||
}
|
||||
|
||||
void PowerManagementInhibitor::onAsyncReply(QDBusPendingCallWatcher *call)
|
||||
bool InhibitorDBus::requestIdle()
|
||||
{
|
||||
m_intendedState = Idle;
|
||||
|
||||
switch (m_state)
|
||||
{
|
||||
case Idle:
|
||||
case RequestIdle:
|
||||
return true;
|
||||
case Error:
|
||||
case RequestBusy:
|
||||
return false;
|
||||
case Busy:
|
||||
break;
|
||||
};
|
||||
|
||||
if (m_manager == ManagerType::Systemd)
|
||||
{
|
||||
m_fd = {};
|
||||
m_state = Idle;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_state = RequestIdle;
|
||||
|
||||
const QString method = (m_manager == ManagerType::Gnome)
|
||||
? u"Uninhibit"_s
|
||||
: u"UnInhibit"_s;
|
||||
const QDBusPendingCall pcall = m_busInterface->asyncCall(method, m_cookie);
|
||||
const auto *watcher = new QDBusPendingCallWatcher(pcall, this);
|
||||
connect(watcher, &QDBusPendingCallWatcher::finished, this, &InhibitorDBus::onAsyncReply);
|
||||
return true;
|
||||
}
|
||||
|
||||
void InhibitorDBus::onAsyncReply(QDBusPendingCallWatcher *call)
|
||||
{
|
||||
call->deleteLater();
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
* Copyright (C) 2011 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -31,20 +32,21 @@
|
|||
#include <QDBusUnixFileDescriptor>
|
||||
#include <QObject>
|
||||
|
||||
#include "inhibitor.h"
|
||||
|
||||
class QDBusInterface;
|
||||
class QDBusPendingCallWatcher;
|
||||
|
||||
class PowerManagementInhibitor final : public QObject
|
||||
class InhibitorDBus final : public QObject, public Inhibitor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY_MOVE(PowerManagementInhibitor)
|
||||
Q_DISABLE_COPY_MOVE(InhibitorDBus)
|
||||
|
||||
public:
|
||||
PowerManagementInhibitor(QObject *parent = nullptr);
|
||||
~PowerManagementInhibitor() override = default;
|
||||
InhibitorDBus(QObject *parent = nullptr);
|
||||
|
||||
void requestIdle();
|
||||
void requestBusy();
|
||||
bool requestBusy() override;
|
||||
bool requestIdle() override;
|
||||
|
||||
private slots:
|
||||
void onAsyncReply(QDBusPendingCallWatcher *call);
|
46
src/gui/powermanagement/inhibitormacos.cpp
Normal file
46
src/gui/powermanagement/inhibitormacos.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
* Copyright (C) 2011 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "inhibitormacos.h"
|
||||
|
||||
#include <QScopeGuard>
|
||||
|
||||
bool InhibitorMacOS::requestBusy()
|
||||
{
|
||||
const CFStringRef assertName = tr("PMMacOS", "qBittorrent is active").toCFString();
|
||||
[[maybe_unused]] const auto assertNameGuard = qScopeGuard([&assertName] { ::CFRelease(assertName); });
|
||||
const IOReturn result = ::IOPMAssertionCreateWithName(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn
|
||||
, assertName, &m_assertionID);
|
||||
return result == kIOReturnSuccess;
|
||||
}
|
||||
|
||||
bool InhibitorMacOS::requestIdle()
|
||||
{
|
||||
return ::IOPMAssertionRelease(m_assertionID) == kIOReturnSuccess;
|
||||
}
|
47
src/gui/powermanagement/inhibitormacos.h
Normal file
47
src/gui/powermanagement/inhibitormacos.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "inhibitor.h"
|
||||
|
||||
class InhibitorMacOS final : public Inhibitor
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(InhibitorMacOS)
|
||||
|
||||
public:
|
||||
bool requestBusy() override;
|
||||
bool requestIdle() override;
|
||||
|
||||
private:
|
||||
IOPMAssertionID m_assertionID {};
|
||||
};
|
42
src/gui/powermanagement/inhibitorwindows.cpp
Normal file
42
src/gui/powermanagement/inhibitorwindows.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
* Copyright (C) 2011 Vladimir Golovnev <glassez@yandex.ru>
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#include "inhibitorwindows.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
bool InhibitorWindows::requestBusy()
|
||||
{
|
||||
return ::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED) != NULL;
|
||||
}
|
||||
|
||||
bool InhibitorWindows::requestIdle()
|
||||
{
|
||||
return ::SetThreadExecutionState(ES_CONTINUOUS) != NULL;
|
||||
}
|
38
src/gui/powermanagement/inhibitorwindows.h
Normal file
38
src/gui/powermanagement/inhibitorwindows.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2025 Mike Tzou (Chocobo1)
|
||||
*
|
||||
* 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 the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* In addition, as a special exception, the copyright holders give permission to
|
||||
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||||
* modified versions of it that use the same license as the "OpenSSL" library),
|
||||
* and distribute the linked executables. You must obey the GNU General Public
|
||||
* License in all respects for all of the code used other than "OpenSSL". If you
|
||||
* modify file(s), you may extend this exception to your version of the file(s),
|
||||
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||||
* exception statement from your version.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "inhibitor.h"
|
||||
|
||||
class InhibitorWindows final : public Inhibitor
|
||||
{
|
||||
public:
|
||||
bool requestBusy() override;
|
||||
bool requestIdle() override;
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue