538 Commits

324 changed files with 23223 additions and 6958 deletions

View File

@@ -8,6 +8,7 @@ on:
env: env:
FLUTTER_VERSION: "3.16.9" FLUTTER_VERSION: "3.16.9"
FLUTTER_RUST_BRIDGE_VERSION: "1.80.1" FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
jobs: jobs:
generate_bridge: generate_bridge:
@@ -49,9 +50,9 @@ jobs:
- name: Install Rust toolchain - name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1 uses: dtolnay/rust-toolchain@v1
with: with:
toolchain: stable toolchain: ${{ env.RUST_VERSION }}
targets: ${{ matrix.job.target }} targets: ${{ matrix.job.target }}
components: '' components: "rustfmt"
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with:

230
.github/workflows/build-macos-arm64.yml vendored Normal file
View File

@@ -0,0 +1,230 @@
name: Flutter Nightly MacOS Arm64 Build
on:
#schedule:
# schedule build every night
# - cron: "0/6 * * * *"
workflow_dispatch:
env:
RUST_VERSION: "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
CARGO_NDK_VERSION: "3.1.2"
LLVM_VERSION: "15.0.6"
FLUTTER_VERSION: "3.19.6"
FLUTTER_RUST_BRIDGE_VERSION: "1.80.1"
# for arm64 linux because official Dart SDK does not work
FLUTTER_ELINUX_VERSION: "3.16.9"
TAG_NAME: "nightly"
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
# vcpkg version: 2024.03.25
VCPKG_COMMIT_ID: "a34c873a9717a888f58dc05268dea15592c2f0ff"
VERSION: "1.2.4"
NDK_VERSION: "r26d"
#signing keys env variable checks
ANDROID_SIGNING_KEY: "${{ secrets.ANDROID_SIGNING_KEY }}"
MACOS_P12_BASE64: "${{ secrets.MACOS_P12_BASE64 }}"
# To make a custom build with your own servers set the below secret values
RS_PUB_KEY: "${{ secrets.RS_PUB_KEY }}"
RENDEZVOUS_SERVER: "${{ secrets.RENDEZVOUS_SERVER }}"
API_SERVER: "${{ secrets.API_SERVER }}"
UPLOAD_ARTIFACT: "${{ inputs.upload-artifact }}"
SIGN_BASE_URL: "${{ secrets.SIGN_BASE_URL }}"
jobs:
build-appimage:
name: Build image ${{ matrix.job.target }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
job:
- {
target: x86_64-unknown-linux-gnu,
arch: x86_64,
}
- {
target: aarch64-unknown-linux-gnu,
arch: aarch64,
}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Rename Binary
run: |
sudo apt-get update -y
sudo apt-get install -y wget libarchive-tools
wget https://github.com/rustdesk/rustdesk/releases/download/nightly/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb
mv rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb rustdesk-${{ env.VERSION }}.deb
- name: Patch archlinux PKGBUILD
if: matrix.job.arch == 'x86_64'
run: |
sed -i "s/x86_64/${{ matrix.job.arch }}/g" res/PKGBUILD
if [[ "${{ matrix.job.arch }}" == "aarch64" ]]; then
sed -i "s/linux\/x64/linux\/arm64/g" ./res/PKGBUILD
fi
bsdtar -zxvf rustdesk-${{ env.VERSION }}.deb
tar -xvf ./data.tar.xz
case ${{ matrix.job.arch }} in
aarch64)
mkdir -p flutter/build/linux/arm64/release/bundle
cp -rf usr/lib/rustdesk/* flutter/build/linux/arm64/release/bundle/
;;
x86_64)
mkdir -p flutter/build/linux/x64/release/bundle
cp -rf usr/lib/rustdesk/* flutter/build/linux/x64/release/bundle/
;;
esac
- name: Build archlinux package
if: matrix.job.arch == 'x86_64'
uses: rustdesk-org/arch-makepkg-action@master
with:
packages: >
llvm
clang
libva
libvdpau
rust
gstreamer
unzip
git
cmake
gcc
curl
wget
nasm
zip
make
pkg-config
clang
gtk3
xdotool
libxcb
libxfixes
alsa-lib
pipewire
python
ttf-arphic-uming
libappindicator-gtk3
pam
gst-plugins-base
gst-plugin-pipewire
scripts: |
cd res && HBB=`pwd`/.. FLUTTER=1 makepkg -f
- name: Publish archlinux package
if: matrix.job.arch == 'x86_64'
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.TAG_NAME }}
files: |
res/rustdesk-${{ env.VERSION }}*.zst
- name: Build appimage package
shell: bash
run: |
# set-up appimage-builder
pushd /tmp
wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.1.0/appimage-builder-1.1.0-x86_64.AppImage
chmod +x appimage-builder-x86_64.AppImage
sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder
popd
# run appimage-builder
pushd appimage
sudo appimage-builder --skip-tests --recipe ./AppImageBuilder-${{ matrix.job.arch }}.yml
- name: Publish appimage package
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.TAG_NAME }}
files: |
./appimage/rustdesk-${{ env.VERSION }}-*.AppImage
build-flatpak:
name: Build Flatpak ${{ matrix.job.target }}
runs-on: ${{ matrix.job.on }}
strategy:
fail-fast: false
matrix:
job:
- {
target: x86_64-unknown-linux-gnu,
distro: ubuntu18.04,
on: ubuntu-20.04,
arch: x86_64,
}
- {
target: aarch64-unknown-linux-gnu,
# try out newer flatpak since error of "error: Nothing matches org.freedesktop.Platform in remote flathub"
distro: ubuntu22.04,
on: [self-hosted, Linux, ARM64],
arch: aarch64,
}
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Rename Binary
run: |
sudo apt-get update -y
sudo apt-get install -y wget
wget https://github.com/rustdesk/rustdesk/releases/download/nightly/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb
mv rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.deb rustdesk-${{ env.VERSION }}.deb
- uses: rustdesk-org/run-on-arch-action@amd64-support
name: Build rustdesk flatpak package for ${{ matrix.job.arch }}
id: rpm
with:
arch: ${{ matrix.job.arch }}
distro: ${{ matrix.job.distro }}
githubToken: ${{ github.token }}
setup: |
ls -l "${PWD}"
dockerRunArgs: |
--volume "${PWD}:/workspace"
shell: /bin/bash
install: |
apt-get update -y
apt-get install -y \
curl \
git \
rpm \
wget
run: |
# disable git safe.directory
git config --global --add safe.directory "*"
pushd /workspace
# install
apt-get update -y
apt-get install -y \
cmake \
curl \
flatpak \
flatpak-builder \
gcc \
git \
g++ \
libgtk-3-dev \
nasm \
wget
# flatpak deps
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install -y flathub org.freedesktop.Platform/${{ matrix.job.arch }}/23.08
flatpak --user install -y flathub org.freedesktop.Sdk/${{ matrix.job.arch }}/23.08
# package
pushd flatpak
git clone https://github.com/flathub/shared-modules.git --depth=1
flatpak-builder --user --force-clean --repo=repo ./build ./rustdesk.json
flatpak build-bundle ./repo rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.flatpak com.rustdesk.RustDesk
- name: Publish flatpak package
uses: softprops/action-gh-release@v1
with:
prerelease: true
tag_name: ${{ env.TAG_NAME }}
files: |
flatpak/rustdesk-${{ env.VERSION }}-${{ matrix.job.arch }}.flatpak

View File

@@ -21,6 +21,9 @@ on:
- ".github/**" - ".github/**"
- "docs/**" - "docs/**"
- "README.md" - "README.md"
- "res/**"
- "appimage/**"
- "flatpak/**"
jobs: jobs:
# ensure_cargo_fmt: # ensure_cargo_fmt:
@@ -71,12 +74,12 @@ jobs:
# - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } # - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
# - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } # - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }
# - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true } # - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }
# - { target: i686-pc-windows-msvc , os: windows-2019 } # - { target: i686-pc-windows-msvc , os: windows-2022 }
# - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } # - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
# - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } # - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
# - { target: x86_64-apple-darwin , os: macos-10.15 } # - { target: x86_64-apple-darwin , os: macos-10.15 }
# - { target: x86_64-pc-windows-gnu , os: windows-2019 } # - { target: x86_64-pc-windows-gnu , os: windows-2022 }
# - { target: x86_64-pc-windows-msvc , os: windows-2019 } # - { target: x86_64-pc-windows-msvc , os: windows-2022 }
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 } - { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
# - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } # - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
steps: steps:
@@ -103,6 +106,7 @@ jobs:
gcc \ gcc \
git \ git \
g++ \ g++ \
libpam0g-dev \
libasound2-dev \ libasound2-dev \
libgstreamer1.0-dev \ libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \ libgstreamer-plugins-base1.0-dev \

37
.github/workflows/clear-cache.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Clear cache
on:
workflow_dispatch:
permissions:
actions: write
jobs:
clear-cache:
runs-on: ubuntu-latest
steps:
- name: Clear cache
uses: actions/github-script@v7
with:
script: |
console.log("About to clear")
const caches = await github.rest.actions.getActionsCacheList({
owner: context.repo.owner,
repo: context.repo.repo,
})
for (const cache of caches.data.actions_caches) {
console.log(cache)
github.rest.actions.deleteActionsCacheById({
owner: context.repo.owner,
repo: context.repo.repo,
cache_id: cache.id,
})
}
console.log("Clear completed")
- name: Purge cache # Above seems not clear thouroughly, so add this to double clear
uses: MyAlbum/purge-cache@v2
with:
accessed: true # Purge caches by their last accessed time (default)
created: false # Purge caches by their created time (default)
max-age: 1 # in seconds

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,9 @@ on:
- ".github/**" - ".github/**"
- "docs/**" - "docs/**"
- "README.md" - "README.md"
- "res/**"
- "appimage/**"
- "flatpak/**"
jobs: jobs:
run-ci: run-ci:

View File

@@ -15,7 +15,7 @@ jobs:
secrets: inherit secrets: inherit
with: with:
upload-artifact: true upload-artifact: true
upload-tag: ${{ env.GITHUB_REF_NAME }} upload-tag: ${{ github.ref_name }}
update-fdroid-version-file: update-fdroid-version-file:
name: Publish RustDesk version file for F-Droid updater name: Publish RustDesk version file for F-Droid updater

View File

@@ -18,7 +18,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
job: job:
- { target: x86_64-pc-windows-msvc, os: windows-2019, arch: x86_64, date: 2023-08-04, ref: 72c198a1e94cc1e0242fce88f92b3f3caedcd0c3 } - { target: x86_64-pc-windows-msvc, os: windows-2022, arch: x86_64, date: 2023-08-04, ref: 72c198a1e94cc1e0242fce88f92b3f3caedcd0c3 }
steps: steps:
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -31,7 +31,7 @@ jobs:
version: ${{ env.LLVM_VERSION }} version: ${{ env.LLVM_VERSION }}
- name: Install flutter - name: Install flutter
uses: subosito/flutter-action@v2 uses: subosito/flutter-action@v2.12.0 #https://github.com/subosito/flutter-action/issues/277
with: with:
channel: "stable" channel: "stable"
flutter-version: ${{ env.FLUTTER_VERSION }} flutter-version: ${{ env.FLUTTER_VERSION }}
@@ -64,7 +64,7 @@ jobs:
shell: bash shell: bash
- name: Build rustdesk - name: Build rustdesk
run: python3 .\build.py --portable --hwcodec --flutter --feature IddDriver run: python3 .\build.py --portable --hwcodec --flutter
- name: Build self-extracted executable - name: Build self-extracted executable
shell: bash shell: bash

View File

@@ -0,0 +1,60 @@
name: build RustDeskTempTopMostWindow
on:
workflow_call:
inputs:
upload-artifact:
type: boolean
default: true
target:
description: 'Target'
required: true
type: string
default: 'windows-2022'
configuration:
description: 'Configuration'
required: true
type: string
default: 'Release'
platform:
description: 'Platform'
required: true
type: string
default: 'x64'
target_version:
description: 'TargetVersion'
required: true
type: string
default: 'Windows10'
env:
project_path: WindowInjection/WindowInjection.vcxproj
jobs:
build-RustDeskTempTopMostWindow:
runs-on: ${{ inputs.target }}
strategy:
fail-fast: false
env:
build_output_dir: RustDeskTempTopMostWindow/WindowInjection/${{ inputs.platform }}/${{ inputs.configuration }}
steps:
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Download the source code
run: |
git clone https://github.com/rustdesk-org/RustDeskTempTopMostWindow RustDeskTempTopMostWindow
# Build. commit 53b548a5398624f7149a382000397993542ad796 is tag v0.3
- name: Build the project
run: |
cd RustDeskTempTopMostWindow && git checkout 53b548a5398624f7149a382000397993542ad796
msbuild ${{ env.project_path }} -p:Configuration=${{ inputs.configuration }} -p:Platform=${{ inputs.platform }} /p:TargetVersion=${{ inputs.target_version }}
- name: Archive build artifacts
uses: actions/upload-artifact@master
if: ${{ inputs.upload-artifact }}
with:
name: topmostwindow-artifacts
path: |
./${{ env.build_output_dir }}/WindowInjection.dll

726
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@ version = "1.2.4"
authors = ["rustdesk <info@rustdesk.com>"] authors = ["rustdesk <info@rustdesk.com>"]
edition = "2021" edition = "2021"
build= "build.rs" build= "build.rs"
description = "A remote control software." description = "RustDesk Remote Desktop"
default-run = "rustdesk" default-run = "rustdesk"
rust-version = "1.75" rust-version = "1.75"
@@ -20,18 +20,14 @@ path = "src/naming.rs"
inline = [] inline = []
cli = [] cli = []
flutter_texture_render = [] flutter_texture_render = []
appimage = []
flatpak = []
use_samplerate = ["samplerate"] use_samplerate = ["samplerate"]
use_rubato = ["rubato"] use_rubato = ["rubato"]
use_dasp = ["dasp"] use_dasp = ["dasp"]
flutter = ["flutter_rust_bridge"] flutter = ["flutter_rust_bridge"]
default = ["use_dasp"] default = ["use_dasp"]
hwcodec = ["scrap/hwcodec"] hwcodec = ["scrap/hwcodec"]
gpucodec = ["scrap/gpucodec"] vram = ["scrap/vram"]
mediacodec = ["scrap/mediacodec"] mediacodec = ["scrap/mediacodec"]
linux_headless = ["pam" ]
virtual_display_driver = ["virtual_display"]
plugin_framework = [] plugin_framework = []
linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"] linux-pkg-config = ["magnum-opus/linux-pkg-config", "scrap/linux-pkg-config"]
unix-file-copy-paste = [ unix-file-copy-paste = [
@@ -45,7 +41,8 @@ unix-file-copy-paste = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
whoami = "1.4" async-trait = "0.1"
whoami = "1.5.0"
scrap = { path = "libs/scrap", features = ["wayland"] } scrap = { path = "libs/scrap", features = ["wayland"] }
hbb_common = { path = "libs/hbb_common" } hbb_common = { path = "libs/hbb_common" }
serde_derive = "1.0" serde_derive = "1.0"
@@ -57,7 +54,6 @@ lazy_static = "1.4"
sha2 = "0.10" sha2 = "0.10"
repng = "0.2" repng = "0.2"
parity-tokio-ipc = { git = "https://github.com/rustdesk-org/parity-tokio-ipc" } parity-tokio-ipc = { git = "https://github.com/rustdesk-org/parity-tokio-ipc" }
runas = "=1.0" # https://github.com/mitsuhiko/rust-runas/issues/13
magnum-opus = { git = "https://github.com/rustdesk-org/magnum-opus" } magnum-opus = { git = "https://github.com/rustdesk-org/magnum-opus" }
dasp = { version = "0.11", features = ["signal", "interpolate-linear", "interpolate"], optional = true } dasp = { version = "0.11", features = ["signal", "interpolate-linear", "interpolate"], optional = true }
rubato = { version = "0.12", optional = true } rubato = { version = "0.12", optional = true }
@@ -65,7 +61,6 @@ samplerate = { version = "0.2", optional = true }
uuid = { version = "1.3", features = ["v4"] } uuid = { version = "1.3", features = ["v4"] }
clap = "4.2" clap = "4.2"
rpassword = "7.2" rpassword = "7.2"
base64 = "0.21"
num_cpus = "1.15" num_cpus = "1.15"
bytes = { version = "1.4", features = ["serde"] } bytes = { version = "1.4", features = ["serde"] }
default-net = "0.14" default-net = "0.14"
@@ -95,18 +90,32 @@ sys-locale = "0.3"
enigo = { path = "libs/enigo", features = [ "with_serde" ] } enigo = { path = "libs/enigo", features = [ "with_serde" ] }
clipboard = { path = "libs/clipboard" } clipboard = { path = "libs/clipboard" }
ctrlc = "3.2" ctrlc = "3.2"
arboard = { version = "3.2", features = ["wayland-data-control"] } arboard = { git = "https://github.com/fufesou/arboard", branch = "feat/x11_set_conn_timeout", features = ["wayland-data-control"] }
system_shutdown = "4.0" system_shutdown = "4.0"
qrcode-generator = "4.1" qrcode-generator = "4.1"
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["winuser", "wincrypt", "shellscalingapi", "pdh", "synchapi", "memoryapi", "shellapi"] } winapi = { version = "0.3", features = [
"winuser",
"wincrypt",
"shellscalingapi",
"pdh",
"synchapi",
"memoryapi",
"shellapi",
"devguid",
"setupapi",
"cguid",
"cfgmgr32",
"ioapiset",
] }
winreg = "0.11" winreg = "0.11"
windows-service = "0.6" windows-service = "0.6"
virtual_display = { path = "libs/virtual_display", optional = true } virtual_display = { path = "libs/virtual_display" }
impersonate_system = { git = "https://github.com/21pages/impersonate-system" } impersonate_system = { git = "https://github.com/21pages/impersonate-system" }
shared_memory = "0.12" shared_memory = "0.12"
tauri-winrt-notification = "0.1.2" tauri-winrt-notification = "0.1.2"
runas = "1.2"
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2" objc = "0.2"
@@ -131,10 +140,10 @@ wallpaper = { git = "https://github.com/21pages/wallpaper.rs" }
[target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies] [target.'cfg(any(target_os = "macos", target_os = "windows"))'.dependencies]
# https://github.com/rustdesk/rustdesk-server-pro/issues/189, using native-tls for better tls support # https://github.com/rustdesk/rustdesk-server-pro/issues/189, using native-tls for better tls support
reqwest = { git = "https://github.com/rustdesk-org/reqwest", features = ["blocking", "json", "native-tls", "gzip"], default-features=false } reqwest = { git = "https://github.com/rustdesk-org/reqwest", features = ["blocking", "socks", "json", "native-tls", "gzip"], default-features=false }
[target.'cfg(not(any(target_os = "macos", target_os = "windows")))'.dependencies] [target.'cfg(not(any(target_os = "macos", target_os = "windows")))'.dependencies]
reqwest = { git = "https://github.com/rustdesk-org/reqwest", features = ["blocking", "json", "rustls-tls", "rustls-tls-native-roots", "gzip"], default-features=false } reqwest = { git = "https://github.com/rustdesk-org/reqwest", features = ["blocking", "socks", "json", "rustls-tls", "rustls-tls-native-roots", "gzip"], default-features=false }
[target.'cfg(target_os = "linux")'.dependencies] [target.'cfg(target_os = "linux")'.dependencies]
psimple = { package = "libpulse-simple-binding", version = "2.27" } psimple = { package = "libpulse-simple-binding", version = "2.27" }
@@ -145,7 +154,7 @@ mouce = { git="https://github.com/fufesou/mouce.git" }
evdev = { git="https://github.com/fufesou/evdev" } evdev = { git="https://github.com/fufesou/evdev" }
dbus = "0.9" dbus = "0.9"
dbus-crossroads = "0.5" dbus-crossroads = "0.5"
pam = { git="https://github.com/fufesou/pam", optional = true } pam = { git="https://github.com/fufesou/pam" }
users = { version = "0.11" } users = { version = "0.11" }
x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch", optional = true} x11-clipboard = {git="https://github.com/clslaid/x11-clipboard", branch = "feat/store-batch", optional = true}
x11rb = {version = "0.12", features = ["all-extensions"], optional = true} x11rb = {version = "0.12", features = ["all-extensions"], optional = true}
@@ -162,9 +171,10 @@ members = ["libs/scrap", "libs/hbb_common", "libs/enigo", "libs/clipboard", "lib
exclude = ["vdi/host", "examples/custom_plugin"] exclude = ["vdi/host", "examples/custom_plugin"]
[package.metadata.winres] [package.metadata.winres]
LegalCopyright = "Copyright © 2023 Purslane, Inc." LegalCopyright = "Copyright © 2024 Purslane Ltd. All rights reserved."
# this FileDescription overrides package.description ProductName = "RustDesk"
FileDescription = "RustDesk" FileDescription = "RustDesk Remote Desktop"
OriginalFilename = "rustdesk.exe"
[target.'cfg(target_os="windows")'.build-dependencies] [target.'cfg(target_os="windows")'.build-dependencies]
winres = "0.1" winres = "0.1"

View File

@@ -13,8 +13,6 @@ Chat with us: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](https://twitt
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I04VU09) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I04VU09)
[![Open Bounties](https://img.shields.io/endpoint?url=https%3A%2F%2Fconsole.algora.io%2Fapi%2Fshields%2Frustdesk%2Fbounties%3Fstatus%3Dopen)](https://console.algora.io/org/rustdesk/bounties?status=open)
Yet another remote desktop software, written in Rust. Works out of the box, no configuration required. You have full control of your data, with no concerns about security. You can use our rendezvous/relay server, [set up your own](https://rustdesk.com/server), or [write your own rendezvous/relay server](https://github.com/rustdesk/rustdesk-server-demo). Yet another remote desktop software, written in Rust. Works out of the box, no configuration required. You have full control of your data, with no concerns about security. You can use our rendezvous/relay server, [set up your own](https://rustdesk.com/server), or [write your own rendezvous/relay server](https://github.com/rustdesk/rustdesk-server-demo).
![image](https://user-images.githubusercontent.com/71636191/171661982-430285f0-2e12-4b1d-9957-4a58e375304d.png) ![image](https://user-images.githubusercontent.com/71636191/171661982-430285f0-2e12-4b1d-9957-4a58e375304d.png)
@@ -31,22 +29,6 @@ RustDesk welcomes contribution from everyone. See [CONTRIBUTING.md](docs/CONTRIB
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Free Public Servers
Below are the servers you are using for free, they may change over time. If you are not close to one of these, your network may be slow.
| Location | Vendor | Specification |
| --------- | ------------- | ------------------ |
| Germany | [Hetzner](https://www.hetzner.com) | 2 vCPU / 4 GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4 GB RAM |
## Dev Container
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
If you already have VS Code and Docker installed, you can click the badge above to get started. Clicking will cause VS Code to automatically install the Dev Containers extension if needed, clone the source code into a container volume, and spin up a dev container for use.
Go through [DEVCONTAINER.md](docs/DEVCONTAINER.md) for more info.
## Dependencies ## Dependencies
Desktop versions use Flutter or Sciter (deprecated) for GUI, this tutorial is for Sciter only, since it is easier and more friendly to start. Check out our [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) for building Flutter version. Desktop versions use Flutter or Sciter (deprecated) for GUI, this tutorial is for Sciter only, since it is easier and more friendly to start. Check out our [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) for building Flutter version.
@@ -180,12 +162,12 @@ Please ensure that you are running these commands from the root of the RustDesk
- **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: Flutter code for desktop and mobile - **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: Flutter code for desktop and mobile
- **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/js)**: JavaScript for Flutter web client - **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/js)**: JavaScript for Flutter web client
## Snapshots ## Screenshots
![image](https://user-images.githubusercontent.com/71636191/113112362-ae4deb80-923b-11eb-957d-ff88daad4f06.png) ![Connection Manager](https://github.com/rustdesk/rustdesk/assets/28412477/db82d4e7-c4bc-4823-8e6f-6af7eadf7651)
![image](https://user-images.githubusercontent.com/71636191/113112619-f705a480-923b-11eb-911d-97e984ef52b6.png) ![Connected to a Windows PC](https://github.com/rustdesk/rustdesk/assets/28412477/9baa91e9-3362-4d06-aa1a-7518edcbd7ea)
![image](https://user-images.githubusercontent.com/71636191/113112857-3fbd5d80-923c-11eb-9836-768325faf906.png) ![File Transfer](https://github.com/rustdesk/rustdesk/assets/28412477/39511ad3-aa9a-4f8c-8947-1cce286a46ad)
![image](https://user-images.githubusercontent.com/71636191/135385039-38fdbd72-379a-422d-b97f-33df71fb1cec.png) ![TCP Tunneling](https://github.com/rustdesk/rustdesk/assets/28412477/78e8708f-e87e-4570-8373-1360033ea6c5)

View File

@@ -2,7 +2,7 @@
version: 1 version: 1
script: script:
- rm -rf ./AppDir || true - rm -rf ./AppDir || true
- bsdtar -zxvf ../rustdesk-1.2.4.deb - bsdtar -zxvf rustdesk.deb
- tar -xvf ./data.tar.xz - tar -xvf ./data.tar.xz
- mkdir ./AppDir - mkdir ./AppDir
- mv ./usr ./AppDir/usr - mv ./usr ./AppDir/usr
@@ -26,18 +26,18 @@ AppDir:
- arm64 - arm64
allow_unauthenticated: true allow_unauthenticated: true
sources: sources:
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted universe multiverse - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32' key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic-updates main restricted universe multiverse - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32' key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic-backports main restricted - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted
universe multiverse universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32' key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
- sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ bionic-security main restricted - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted
universe multiverse universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32' key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
include: include:
- libc6 - libc6:arm64
- libgtk-3-0 - libgtk-3-0
- libxcb-randr0 - libxcb-randr0
- libxdo3 - libxdo3
@@ -51,9 +51,15 @@ AppDir:
- libva-x11-2 - libva-x11-2
- libvdpau1 - libvdpau1
- libgstreamer-plugins-base1.0-0 - libgstreamer-plugins-base1.0-0
- gstreamer1.0-pipewire
- libwayland-client0
- libwayland-cursor0 - libwayland-cursor0
- libwayland-egl1 - libwayland-egl1
- libpulse0 - libpulse0
- packagekit-gtk3-module
- libcanberra-gtk3-module
- libpam0g
- libdrm2
exclude: exclude:
- humanity-icon-theme - humanity-icon-theme
- hicolor-icon-theme - hicolor-icon-theme
@@ -69,8 +75,11 @@ AppDir:
- usr/share/doc/*/TODO.* - usr/share/doc/*/TODO.*
runtime: runtime:
env: env:
GIO_MODULE_DIR: $APPDIR/usr/lib/x86_64-linux-gnu/gio/modules/ GIO_MODULE_DIR: /lib64/gio/modules:/usr/lib/aarch64-linux-gnu/gio/modules:$APPDIR/usr/lib/aarch64-linux-gnu/gio/modules
GDK_BACKEND: x11 GDK_BACKEND: x11
APPDIR_LIBRARY_PATH: /lib64:/usr/lib/aarch64-linux-gnu:$APPDIR/lib/aarch64-linux-gnu:$APPDIR/lib/aarch64-linux-gnu/security:$APPDIR/lib/systemd:$APPDIR/usr/lib/aarch64-linux-gnu:$APPDIR/usr/lib/aarch64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gtk-3.0/3.0.0/immodules:$APPDIR/usr/lib/aarch64-linux-gnu/gtk-3.0/3.0.0/printbackends:$APPDIR/usr/lib/aarch64-linux-gnu/krb5/plugins/preauth:$APPDIR/usr/lib/aarch64-linux-gnu/libcanberra-0.30:$APPDIR/usr/lib/aarch64-linux-gnu/pulseaudio:$APPDIR/usr/lib/aarch64-linux-gnu/sasl2:$APPDIR/usr/lib/aarch64-linux-gnu/vdpau:$APPDIR/usr/lib/rustdesk/lib:$APPDIR/lib/aarch64
GST_PLUGIN_PATH: /lib64/gstreamer-1.0:/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0
GST_PLUGIN_SYSTEM_PATH: /lib64/gstreamer-1.0:/usr/lib/aarch64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/aarch64-linux-gnu/gstreamer-1.0
test: test:
fedora-30: fedora-30:
image: appimagecrafters/tests-env:fedora-30 image: appimagecrafters/tests-env:fedora-30

View File

@@ -2,7 +2,7 @@
version: 1 version: 1
script: script:
- rm -rf ./AppDir || true - rm -rf ./AppDir || true
- bsdtar -zxvf ../rustdesk-1.2.4.deb - bsdtar -zxvf rustdesk.deb
- tar -xvf ./data.tar.xz - tar -xvf ./data.tar.xz
- mkdir ./AppDir - mkdir ./AppDir
- mv ./usr ./AppDir/usr - mv ./usr ./AppDir/usr
@@ -26,18 +26,16 @@ AppDir:
- amd64 - amd64
allow_unauthenticated: true allow_unauthenticated: true
sources: sources:
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic main restricted - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic universe - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates universe
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic multiverse - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted
universe multiverse universe multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-security main restricted - sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted
universe multiverse universe multiverse
- sourceline: deb http://ppa.launchpad.net/pipewire-debian/pipewire-upstream/ubuntu
bionic main
include: include:
- libc6:amd64 - libc6:amd64
- libgtk-3-0 - libgtk-3-0
@@ -54,9 +52,14 @@ AppDir:
- libvdpau1 - libvdpau1
- libgstreamer-plugins-base1.0-0 - libgstreamer-plugins-base1.0-0
- gstreamer1.0-pipewire - gstreamer1.0-pipewire
- libwayland-client0
- libwayland-cursor0 - libwayland-cursor0
- libwayland-egl1 - libwayland-egl1
- libpulse0 - libpulse0
- packagekit-gtk3-module
- libcanberra-gtk3-module
- libpam0g
- libdrm2
exclude: exclude:
- humanity-icon-theme - humanity-icon-theme
- hicolor-icon-theme - hicolor-icon-theme
@@ -72,8 +75,11 @@ AppDir:
- usr/share/doc/*/TODO.* - usr/share/doc/*/TODO.*
runtime: runtime:
env: env:
GIO_MODULE_DIR: $APPDIR/usr/lib/x86_64-linux-gnu/gio/modules/ GIO_MODULE_DIR: /lib64/gio/modules:/usr/lib/x86_64-linux-gnu/gio/modules:$APPDIR/usr/lib/x86_64-linux-gnu/gio/modules
GDK_BACKEND: x11 GDK_BACKEND: x11
APPDIR_LIBRARY_PATH: /lib64:/usr/lib/x86_64-linux-gnu:$APPDIR/lib/x86_64-linux-gnu:$APPDIR/lib/x86_64-linux-gnu/security:$APPDIR/lib/systemd:$APPDIR/usr/lib/x86_64-linux-gnu:$APPDIR/usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders:$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules:$APPDIR/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/printbackends:$APPDIR/usr/lib/x86_64-linux-gnu/krb5/plugins/preauth:$APPDIR/usr/lib/x86_64-linux-gnu/libcanberra-0.30:$APPDIR/usr/lib/x86_64-linux-gnu/pulseaudio:$APPDIR/usr/lib/x86_64-linux-gnu/sasl2:$APPDIR/usr/lib/x86_64-linux-gnu/vdpau:$APPDIR/usr/lib/rustdesk/lib:$APPDIR/lib/x86_64
GST_PLUGIN_PATH: /lib64/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer-1.0
GST_PLUGIN_SYSTEM_PATH: /lib64/gstreamer-1.0:/usr/lib/x86_64-linux-gnu/gstreamer-1.0:$APPDIR/usr/lib/x86_64-linux-gnu/gstreamer-1.0
test: test:
fedora-30: fedora-30:
image: appimagecrafters/tests-env:fedora-30 image: appimagecrafters/tests-env:fedora-30

View File

@@ -33,9 +33,9 @@ def get_arch() -> str:
def system2(cmd): def system2(cmd):
err = os.system(cmd) exit_code = os.system(cmd)
if err != 0: if exit_code != 0:
print(f"Error occurred when executing: {cmd}. Exiting.") sys.stderr.write(f"Error occurred when executing: `{cmd}`. Exiting.\n")
sys.exit(-1) sys.exit(-1)
@@ -80,8 +80,10 @@ def parse_rc_features(feature):
return get_all_features() return get_all_features()
elif isinstance(feature, list): elif isinstance(feature, list):
if windows: if windows:
# download third party is deprecated, we use github ci instead.
# force add PrivacyMode # force add PrivacyMode
feature.append('PrivacyMode') # feature.append('PrivacyMode')
pass
for feat in feature: for feat in feature:
if isinstance(feat, str) and feat.upper() == 'ALL': if isinstance(feat, str) and feat.upper() == 'ALL':
return get_all_features() return get_all_features()
@@ -109,6 +111,8 @@ def make_parser():
'Available: PrivacyMode. Special value is "ALL" and empty "". Default is empty.') 'Available: PrivacyMode. Special value is "ALL" and empty "". Default is empty.')
parser.add_argument('--flutter', action='store_true', parser.add_argument('--flutter', action='store_true',
help='Build flutter package', default=False) help='Build flutter package', default=False)
parser.add_argument('--disable-flutter-texture-render', action='store_true',
help='Build flutter package', default=False)
parser.add_argument( parser.add_argument(
'--hwcodec', '--hwcodec',
action='store_true', action='store_true',
@@ -116,9 +120,9 @@ def make_parser():
'' if windows or osx else ', need libva-dev, libvdpau-dev.') '' if windows or osx else ', need libva-dev, libvdpau-dev.')
) )
parser.add_argument( parser.add_argument(
'--gpucodec', '--vram',
action='store_true', action='store_true',
help='Enable feature gpucodec, only available on windows now.' help='Enable feature vram, only available on windows now.'
) )
parser.add_argument( parser.add_argument(
'--portable', '--portable',
@@ -130,21 +134,17 @@ def make_parser():
action='store_true', action='store_true',
help='Build with unix file copy paste feature' help='Build with unix file copy paste feature'
) )
parser.add_argument(
'--flatpak',
action='store_true',
help='Build rustdesk libs with the flatpak feature enabled'
)
parser.add_argument(
'--appimage',
action='store_true',
help='Build rustdesk libs with the appimage feature enabled'
)
parser.add_argument( parser.add_argument(
'--skip-cargo', '--skip-cargo',
action='store_true', action='store_true',
help='Skip cargo build process, only flutter version + Linux supported currently' help='Skip cargo build process, only flutter version + Linux supported currently'
) )
if windows:
parser.add_argument(
'--skip-portable-pack',
action='store_true',
help='Skip packing, only flutter version + Windows supported'
)
parser.add_argument( parser.add_argument(
"--package", "--package",
type=str type=str
@@ -188,6 +188,9 @@ def generate_build_script_for_docker():
system2("bash /tmp/build.sh") system2("bash /tmp/build.sh")
# Downloading third party resources is deprecated.
# We can use this function in an offline build environment.
# Even in an online environment, we recommend building third-party resources yourself.
def download_extract_features(features, res_dir): def download_extract_features(features, res_dir):
import re import re
@@ -271,15 +274,12 @@ def get_features(args):
features = ['inline'] if not args.flutter else [] features = ['inline'] if not args.flutter else []
if args.hwcodec: if args.hwcodec:
features.append('hwcodec') features.append('hwcodec')
if args.gpucodec: if args.vram:
features.append('gpucodec') features.append('vram')
if args.flutter: if args.flutter:
features.append('flutter') features.append('flutter')
features.append('flutter_texture_render') if not args.disable_flutter_texture_render:
if args.flatpak: features.append('flutter_texture_render')
features.append('flatpak')
if args.appimage:
features.append('appimage')
if args.unix_file_copy_paste: if args.unix_file_copy_paste:
features.append('unix-file-copy-paste') features.append('unix-file-copy-paste')
print("features:", features) print("features:", features)
@@ -410,9 +410,11 @@ def build_flutter_dmg(version, features):
"cp target/release/liblibrustdesk.dylib target/release/librustdesk.dylib") "cp target/release/liblibrustdesk.dylib target/release/librustdesk.dylib")
os.chdir('flutter') os.chdir('flutter')
system2('flutter build macos --release') system2('flutter build macos --release')
'''
system2( system2(
"create-dmg --volname \"RustDesk Installer\" --window-pos 200 120 --window-size 800 400 --icon-size 100 --app-drop-link 600 185 --icon RustDesk.app 200 190 --hide-extension RustDesk.app rustdesk.dmg ./build/macos/Build/Products/Release/RustDesk.app") "create-dmg --volname \"RustDesk Installer\" --window-pos 200 120 --window-size 800 400 --icon-size 100 --app-drop-link 600 185 --icon RustDesk.app 200 190 --hide-extension RustDesk.app rustdesk.dmg ./build/macos/Build/Products/Release/RustDesk.app")
os.rename("rustdesk.dmg", f"../rustdesk-{version}.dmg") os.rename("rustdesk.dmg", f"../rustdesk-{version}.dmg")
'''
os.chdir("..") os.chdir("..")
@@ -427,7 +429,7 @@ def build_flutter_arch_manjaro(version, features):
system2('HBB=`pwd`/.. FLUTTER=1 makepkg -f') system2('HBB=`pwd`/.. FLUTTER=1 makepkg -f')
def build_flutter_windows(version, features): def build_flutter_windows(version, features, skip_portable_pack):
if not skip_cargo: if not skip_cargo:
system2(f'cargo build --features {features} --lib --release') system2(f'cargo build --features {features} --lib --release')
if not os.path.exists("target/release/librustdesk.dll"): if not os.path.exists("target/release/librustdesk.dll"):
@@ -438,6 +440,8 @@ def build_flutter_windows(version, features):
os.chdir('..') os.chdir('..')
shutil.copy2('target/release/deps/dylib_virtual_display.dll', shutil.copy2('target/release/deps/dylib_virtual_display.dll',
flutter_build_dir_2) flutter_build_dir_2)
if skip_portable_pack:
return
os.chdir('libs/portable') os.chdir('libs/portable')
system2('pip3 install -r requirements.txt') system2('pip3 install -r requirements.txt')
system2( system2(
@@ -487,7 +491,7 @@ def main():
os.chdir('../../..') os.chdir('../../..')
if flutter: if flutter:
build_flutter_windows(version, features) build_flutter_windows(version, features, args.skip_portable_pack)
return return
system2('cargo build --release --features ' + features) system2('cargo build --release --features ' + features)
# system2('upx.exe target/release/rustdesk.exe') # system2('upx.exe target/release/rustdesk.exe')

View File

@@ -1,9 +1,11 @@
#[cfg(windows)] #[cfg(windows)]
fn build_windows() { fn build_windows() {
let file = "src/platform/windows.cc"; let file = "src/platform/windows.cc";
cc::Build::new().file(file).compile("windows"); let file2 = "src/platform/windows_delete_test_cert.cc";
cc::Build::new().file(file).file(file2).compile("windows");
println!("cargo:rustc-link-lib=WtsApi32"); println!("cargo:rustc-link-lib=WtsApi32");
println!("cargo:rerun-if-changed={}", file); println!("cargo:rerun-if-changed={}", file);
println!("cargo:rerun-if-changed={}", file2);
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]

View File

@@ -27,14 +27,6 @@
[**BINARY تنزيل**](https://github.com/rustdesk/rustdesk/releases) [**BINARY تنزيل**](https://github.com/rustdesk/rustdesk/releases)
## خوادم مفتوحة ومجانية
فيما يلي الخوادم التي تستخدمها مجانًا، وقد تتغير طوال الوقت. إذا لم تكن قريبًا من أحد هؤلاء، فقد تكون شبكتك بطيئة.
| الموقع | المورد | المواصفات |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4 GB RAM |
## التبعيات ## التبعيات
لواجهة المستخدم الرسومية [sciter](https://sciter.com/) نسخة سطح المكتب تستخدم لواجهة المستخدم الرسومية [sciter](https://sciter.com/) نسخة سطح المكتب تستخدم

View File

@@ -22,14 +22,6 @@ Projekt RustDesk vítá přiložení ruky k dílu od každého. Jak začít se d
[**STAHOVÁNÍ ZKOMPILOVANÝCH APLIKACÍ**](https://github.com/rustdesk/rustdesk/releases) [**STAHOVÁNÍ ZKOMPILOVANÝCH APLIKACÍ**](https://github.com/rustdesk/rustdesk/releases)
## Veřejné, zdarma službu nabízející servery
Níže jsou uvedeny servery zdarma k vašemu použití (údaje se mohou v čase měnit). Pokud se nenacházíte v oblastech světa poblíž nich, spojení může být pomalé.
| umístění | dodavatel | parametry |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4 GB RAM |
## Softwarové součásti, na kterých závisí ## Softwarové součásti, na kterých závisí
Varianta pro počítač používá pro grafické uživatelské rozhraní [sciter](https://sciter.com/) stáhněte si potřebnou knihovnu. Varianta pro počítač používá pro grafické uživatelské rozhraní [sciter](https://sciter.com/) stáhněte si potřebnou knihovnu.

View File

@@ -19,14 +19,6 @@ RustDesk hilser bidrag fra alle velkommen. Se [`docs/CONTRIBUTING.md`](docs/CONT
[**PROGRAM DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases) [**PROGRAM DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases)
## Gratis offentlige servere
Nedenfor er de servere, du bruger gratis, det kan ændre sig med tiden. Hvis du ikke er tæt på en af disse, kan dit netværk være langsomt.
| Beliggenhed | Udbyder | Specifikation |
| ---------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## Afhængigheder ## Afhængigheder
Desktopversioner bruger [sciter](https://sciter.com/) eller Flutter til GUI, denne vejledning er kun for Sciter. Desktopversioner bruger [sciter](https://sciter.com/) eller Flutter til GUI, denne vejledning er kun for Sciter.

View File

@@ -29,22 +29,6 @@ RustDesk heißt jegliche Mitarbeit willkommen. Schauen Sie sich [CONTRIBUTING-DE
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Freie öffentliche Server
Nachfolgend sind die Server gelistet, die Sie kostenlos nutzen können. Es kann sein, dass sich diese Liste immer mal wieder ändert. Falls Sie nicht in der Nähe einer dieser Server sind, kann es sein, dass Ihre Verbindung langsam sein wird.
| Standort | Anbieter | Spezifikation |
| --------- | ------------- | ------------------ |
| Deutschland | [Hetzner](https://www.hetzner.com/de/) | 2 vCPU / 4 GB RAM |
| Ukraine (Kiew) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4 GB RAM |
## Dev-Container
[![In Dev-Containern öffnen](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Wenn Sie VS Code und Docker bereits installiert haben, können Sie auf das Abzeichen oben klicken, um loszulegen. Wenn Sie darauf klicken, wird VS Code automatisch die Dev-Container-Erweiterung installieren, den Quellcode in ein Container-Volume klonen und einen Dev-Container für die Verwendung aufsetzen.
Weitere Informationen finden Sie in [DEVCONTAINER-DE.md](DEVCONTAINER-DE.md).
## Abhängigkeiten ## Abhängigkeiten
Desktop-Versionen verwenden [Sciter](https://sciter.com/) oder Flutter für die GUI, dieses Tutorial ist nur für Sciter. Desktop-Versionen verwenden [Sciter](https://sciter.com/) oder Flutter für die GUI, dieses Tutorial ist nur für Sciter.

View File

@@ -19,14 +19,6 @@ RustDesk bonvenigas kontribuon de ĉiuj. Vidu [`docs/CONTRIBUTING.md`](CONTRIBUT
[**BINARA ELŜUTO**](https://github.com/rustdesk/rustdesk/releases) [**BINARA ELŜUTO**](https://github.com/rustdesk/rustdesk/releases)
## Senpagaj publikaj serviloj
Malsupre estas la serviloj, kiuj vi uzas senpage, ĝi povas ŝanĝi laŭlonge de la tempo. Se vi ne estas proksima de unu de tiuj, via reto povas esti malrapida.
| Situo | Vendanto | Detaloj |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dependantaĵoj ## Dependantaĵoj
La labortabla versio uzas [sciter](https://sciter.com/) por la interfaco, bonvolu elŝuti la bibliotekon dinamikan sciter. La labortabla versio uzas [sciter](https://sciter.com/) por la interfaco, bonvolu elŝuti la bibliotekon dinamikan sciter.

View File

@@ -25,15 +25,6 @@ RustDesk agradece la contribución de todo el mundo. Lee [`docs/CONTRIBUTING.md`
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Servidores gratis de uso público
A continuación se muestran los servidores gratuitos, pueden cambiar a medida que pasa el tiempo. Si no estás cerca de uno de ellos, tu conexión puede ser lenta.
| Ubicación | Compañía | Especificación |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dependencias ## Dependencias
La versión Desktop usa [Sciter](https://sciter.com/) o Flutter para el GUI, este tutorial es solo para Sciter. La versión Desktop usa [Sciter](https://sciter.com/) o Flutter para el GUI, este tutorial es solo para Sciter.

View File

@@ -25,13 +25,6 @@
[دریافت نرم‌افزار](https://github.com/rustdesk/rustdesk/releases) [دریافت نرم‌افزار](https://github.com/rustdesk/rustdesk/releases)
## سرورهای عمومی رایگان
شما مي‌توانید از سرورهای زیر به رایگان استفاده کنید. این لیست ممکن است به مرور زمان تغییر می‌کند. اگر به این سرورها نزدیک نیستید، ممکن است اتصال شما کند باشد.
| موقعیت | سرویس دهنده | مشخصات |
| --------- | ------------- | ------------------ |
| آلمان | Hetzner | 2 vCPU / 4GB RAM |
## وابستگی ها ## وابستگی ها
نسخه‌های رومیزی از [sciter](https://sciter.com/) برای رابط کاربری گرافیکی استفاده می‌کنند. خواهشمندیم کتابخانه‌ی پویای sciter را خودتان دانلود کنید از این منابع دریافت کنید. نسخه‌های رومیزی از [sciter](https://sciter.com/) برای رابط کاربری گرافیکی استفاده می‌کنند. خواهشمندیم کتابخانه‌ی پویای sciter را خودتان دانلود کنید از این منابع دریافت کنید.

View File

@@ -19,14 +19,6 @@ RustDesk toivottaa avustukset tervetulleiksi kaikilta. Katso lisätietoja [`docs
[**BINAARILATAUS**](https://github.com/rustdesk/rustdesk/releases) [**BINAARILATAUS**](https://github.com/rustdesk/rustdesk/releases)
## Vapaita julkisia palvelimia
Alla on palvelimia, joita voit käyttää ilmaiseksi, ne saattavat muuttua ajan mittaan. Jos et ole lähellä yhtä näistä, verkkosi voi olla hidas.
| Sijainti | Myyjä | Määrittely |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Riippuvuudet ## Riippuvuudet
Desktop-versiot käyttävät [sciter](https://sciter.com/) graafisena käyttöliittymänä, lataa sciter-dynaaminen kirjasto itsellesi. Desktop-versiot käyttävät [sciter](https://sciter.com/) graafisena käyttöliittymänä, lataa sciter-dynaaminen kirjasto itsellesi.

View File

@@ -19,14 +19,6 @@ RustDesk accueille les contributions de tout le monde. Voir [`docs/CONTRIBUTING.
[**TÉLÉCHARGEMENT BINAIRE**](https://github.com/rustdesk/rustdesk/releases) [**TÉLÉCHARGEMENT BINAIRE**](https://github.com/rustdesk/rustdesk/releases)
## Serveurs publics libres
Ci-dessous se trouvent les serveurs que vous utilisez gratuitement, cela peut changer au fil du temps. Si vous n'êtes pas proche de l'un d'entre eux, votre réseau peut être lent.
| Location | Vendor | Specification |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## Dépendances ## Dépendances
Les versions de bureau utilisent [sciter](https://sciter.com/) pour l'interface graphique, veuillez télécharger la bibliothèque dynamique sciter vous-même. Les versions de bureau utilisent [sciter](https://sciter.com/) pour l'interface graphique, veuillez télécharger la bibliothèque dynamique sciter vous-même.

View File

@@ -29,22 +29,6 @@
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Δωρεάν δημόσιοι διακομιστές
Παρακάτω είναι οι διακομιστές που χρησιμοποιούνται δωρεάν, ενδέχεται να αλλάξουν με την πάροδο του χρόνου. Εάν δεν είστε κοντά σε ένα από αυτούς, το δίκτυό σας ίσως να είναι αργό.
| Περιοχή | Πάροχος | Προδιαγραφές |
| --------- | ------------- | ------------------ |
| Γερμανία | Hetzner | 2 vCPU / 4GB RAM |
| Ουκρανία (Κίεβο) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dev Container
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Αν έχετε εγκατεστημένα το VS Code και το Docker, μπορείτε να ξεκινήσετε κάνοντας κλικ στην παραπάνω εικόνα. Αυτό θα έχει ως αποτέλεσμα, το VS Code να εγκαταστήσει αυτόματα την επέκταση Dev Containers, εάν χρειάζεται, θα κλωνοποιήσει τον πηγαίο κώδικα σε έναν νέο container και θα εκκινήσει ένα Dev Container για χρήση προγραμματισμού.
Για περισσότερες πληροφορίες μεταβείτε στο [DEVCONTAINER.md](docs/DEVCONTAINER.md).
## Προαπαιτούμενα για build ## Προαπαιτούμενα για build
Στις παραθυρικές εκδόσεις χρησιμοποιείται είτε το [sciter](https://sciter.com/) είτε το Flutter, τα παρακάτω βήματα είναι μόνο για το Sciter. Στις παραθυρικές εκδόσεις χρησιμοποιείται είτε το [sciter](https://sciter.com/) είτε το Flutter, τα παρακάτω βήματα είναι μόνο για το Sciter.

View File

@@ -27,14 +27,6 @@ A RustDesk szívesen fogad minden contributiont, támogatást mindenkitől. Lás
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Ingyenes publikus szerverek
Ezalatt az üzenet alatt találhatóak azok a publikus szerverek, amelyeket ingyen használhatsz. Ezek a szerverek változhatnak a jövőben, illetve a hálózatuk lehet hogy lassú lehet.
| Hely | Host | Specifikáció |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dependencies ## Dependencies
Az asztali verziók [sciter](https://sciter.com/)-t használnak a GUI-hoz, kérlek telepítsd a dynamikus könyvtárat magad. Az asztali verziók [sciter](https://sciter.com/)-t használnak a GUI-hoz, kérlek telepítsd a dynamikus könyvtárat magad.

View File

@@ -31,20 +31,6 @@ RustDesk mengajak semua orang untuk ikut berkontribusi. Lihat [`docs/CONTRIBUTIN
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Server Publik Gratis
Di bawah ini merupakan server gratis yang bisa kamu gunakan, seiring dengan waktu mungkin akan terjadi perubahan spesifikasi pada setiap server yang ada. Jika lokasi kamu berada jauh dengan salah satu server yang tersedia, kemungkinan koneksi akan terasa lambat ketika melakukan proses remote.
| Lokasi | Penyedia | Spesifikasi |
| --------- | ------------- | ------------------ |
| Jerman | [Hetzner](https://www.hetzner.com) | 2 vCPU / 4GB RAM |
| Ukraina (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dev Container
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Apabila PC kamu sudah terinstal VS Code dan Docker, kamu bisa mengklik badge yang ada diatas untuk memulainya. Dengan mengklik badge tersebut secara otomatis akan menginstal ekstensi pada VS Code, lakukan kloning (clone) source code kedalam container volume, dan aktifkan dev container untuk menggunakannya.
## Dependensi ## Dependensi
Pada versi desktop, antarmuka pengguna (GUI) menggunakan [Sciter](https://sciter.com/) atau flutter Pada versi desktop, antarmuka pengguna (GUI) menggunakan [Sciter](https://sciter.com/) atau flutter

View File

@@ -4,8 +4,8 @@
<a href="#passaggi-per-la-compilazione">Compilazione</a> • <a href="#passaggi-per-la-compilazione">Compilazione</a> •
<a href="#come-compilare-con-docker">Docker</a> • <a href="#come-compilare-con-docker">Docker</a> •
<a href="#struttura-dei-file">Struttura</a> • <a href="#struttura-dei-file">Struttura</a> •
<a href="#screenshots">Schermate</a><br> <a href="#schermate">Schermate</a><br>
[<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-VN.md">Tiếng Việt</a>] | [<a href="README-GR.md">Ελληνικά</a>]<br> [<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-VN.md">Tiếng Việt</a>] | [<a href="README-DA.md">Dansk</a>] | [<a href="README-GR.md">Ελληνικά</a>] | [<a href="README-TR.md">Türkçe</a>]<br>
<b>Abbiamo bisogno del tuo aiuto per tradurre questo file README e la <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">UI RustDesk</a> nella tua lingua nativa</b> <b>Abbiamo bisogno del tuo aiuto per tradurre questo file README e la <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">UI RustDesk</a> nella tua lingua nativa</b>
</p> </p>
@@ -13,28 +13,29 @@ Chatta con noi su: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](https://
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I04VU09) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I04VU09)
Ancora un altro software per il controllo remoto del desktop, scritto in Rust. [![Bounties aperti](https://img.shields.io/endpoint?url=https%3A%2F%2Fconsole.algora.io%2Fapi%2Fshields%2Frustdesk%2Fbounties%3Fstatus%3Dopen)](https://console.algora.io/org/rustdesk/bounties?status=open)
Funziona immediatamente, nessuna configurazione richiesta. Hai il pieno controllo dei tuoi dati, senza preoccupazioni per la sicurezza.
Puoi usare il nostro server rendezvous/relay, [configurare il tuo server](https://rustdesk.com/server) o [realizzare il tuo server rendezvous/relay](https://github.com/rustdesk/rustdesk-server-demo).
RustDesk accoglie il contributo di tutti. Ancora un altro software per il controllo remoto del desktop, scritto in Rust. Funziona immediatamente, nessuna configurazione richiesta. Hai il pieno controllo dei tuoi dati, senza preoccupazioni per la sicurezza. Puoi usare il nostro server rendezvous/relay, [configurare il tuo server](https://rustdesk.com/server) o [realizzare il tuo server rendezvous/relay](https://github.com/rustdesk/rustdesk-server-demo).
Per ulteriori informazioni su come iniziare a contribuire, vedi [`docs/CONTRIBUTING-IT.md`](CONTRIBUTING.md).
[**DOWNLOAD PROGRAMMA**](https://github.com/rustdesk/rustdesk/releases) ![image](https://user-images.githubusercontent.com/71636191/171661982-430285f0-2e12-4b1d-9957-4a58e375304d.png)
## Server pubblici gratuiti RustDesk accoglie il contributo di tutti. Per ulteriori informazioni su come iniziare a contribuire, vedi [CONTRIBUTING.md](CONTRIBUTING-IT.md).
Qui sotto trovi i server che possono essere usati gratuitamente, la lista potrebbe cambiare nel tempo. [**FAQ**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
Se non sei vicino a uno di questi server, la connessione potrebbe essere lenta.
| Posizione | Venditore | Specifiche | [**SCARICA PROGRAMMA**](https://github.com/rustdesk/rustdesk/releases)
| --------- | ------------- | ------------------ |
| Germania | Hetzner | 2 vCPU / 4GB RAM | [**SCARICA NIGHTLY**](https://github.com/rustdesk/rustdesk/releases/tag/nightly)
| Ucraina (Kyev) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Dipendenze ## Dipendenze
La versione Desktop usa per la GUI [sciter](https://sciter.com/), per favore scarica la libreria dinamica sciter. Le versioni desktop utilizzano Flutter o Sciter (deprecato) per l'interfaccia utente, questo tutorial è solo per Sciter, poiché è più facile per iniziare. Controlla il nostro [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) per la compilazione della versione Flutter.
Scarica la libreria dinamica Sciter.
[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | [Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) |
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | [Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
@@ -51,12 +52,22 @@ La versione Desktop usa per la GUI [sciter](https://sciter.com/), per favore sca
- Esegui `cargo run` - Esegui `cargo run`
## [Build](https://rustdesk.com/docs/en/dev/build/)
## Come compilare in Linux ## Come compilare in Linux
### Ubuntu 18 (Debian 10) ### Ubuntu 18 (Debian 10)
```sh ```sh
sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake sudo apt install -y zip g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev \
libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake make \
libclang-dev ninja-build libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
```
### openSUSE Tumbleweed
```sh
sudo zypper install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-devel libXfixes-devel cmake alsa-lib-devel gstreamer-devel gstreamer-plugins-base-devel xdotool-devel
``` ```
### Fedora 28 (CentOS 8) ### Fedora 28 (CentOS 8)
@@ -125,10 +136,7 @@ Quindi, ogni volta che devi compilare l'applicazione, esegui il seguente comando
docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder
``` ```
Tieni presente che la prima build potrebbe richiedere più tempo prima che le dipendenze vengano memorizzate nella cache, le build successive saranno più veloci. Tieni presente che la prima build potrebbe richiedere più tempo prima che le dipendenze vengano memorizzate nella cache, le build successive saranno più veloci. Inoltre, se hai bisogno di specificare argomenti diversi per il comando build, puoi farlo alla fine del comando nella posizione `<OPTIONAL-ARGS>`. Ad esempio, se vuoi creare una versione di rilascio ottimizzata, esegui il comando precedentemente indicato seguito da `--release`. L'eseguibile generato sarà creato nella cartella destinazione del sistema e può essere eseguito con:
Inoltre, se hai bisogno di specificare argomenti diversi per il comando build, puoi farlo alla fine del comando nella posizione `<OPTIONAL-ARGS>`.
Ad esempio, se vuoi creare una versione di rilascio ottimizzata, esegui il comando precedentemente indicato seguito da `--release`.
L'eseguibile generato sarà creato nella cartella destinazione del sistema e può essere eseguito con:
```sh ```sh
target/debug/rustdesk target/debug/rustdesk
@@ -140,19 +148,21 @@ Oppure, se stai avviando un eseguibile di rilascio:
target/release/rustdesk target/release/rustdesk
``` ```
Assicurati di eseguire questi comandi dalla radice del repository RustDesk, altrimenti l'applicazione potrebbe non essere in grado di trovare le risorse richieste. Assicurati di eseguire questi comandi dalla radice del repository RustDesk, altrimenti l'applicazione potrebbe non essere in grado di trovare le risorse richieste. Nota inoltre che altri sottocomandi cargo come `install` o `run` non sono attualmente supportati tramite questo metodo poiché installerebbero o eseguirebbero il programma all'interno del container anziché nell'host.
Nota inoltre che altri sottocomandi cargo come `install` o `run` non sono attualmente supportati tramite questo metodo poiché installerebbero o eseguirebbero il programma all'interno del container anziché nell'host.
## Struttura dei file ## Struttura dei file
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: codec video, config, wrapper tcp/udp, protobuf, funzioni per il trasferimento file, e altre funzioni utili. - **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: codec video, config, wrapper tcp/udp, protobuf, funzioni per il trasferimento file, e altre funzioni utili.
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: cattura dello schermo - **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: cattura dello schermo
- **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: controllo tastiera/mouse specifico della piattaforma - **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: controllo tastiera/mouse specifico della piattaforma
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: GUI - **[libs/clipboard](https://github.com/rustdesk/rustdesk/tree/master/libs/clipboard)**: implementazione del copia e incolla dei file per Windows, Linux, macOS.
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: Sciter UI obsoleto (deprecato)
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: servizi audio/appunti/input/video e connessioni di rete - **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: servizi audio/appunti/input/video e connessioni di rete
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: avvio di una connessione peer - **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: avvio di una connessione peer
- **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: Comunica con [rustdesk-server](https://github.com/rustdesk/rustdesk-server), attende la connessione remota diretta (TCP hole punching) oppure indiretta (relayed) - **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: comunica con [rustdesk-server](https://github.com/rustdesk/rustdesk-server), attende la connessione remota diretta (TCP hole punching) oppure indiretta (relayed)
- **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: codice specifico della piattaforma - **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: codice specifico della piattaforma
- **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: codice Flutter per desktop e mobile
- **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/js)**: JavaScript per client web Flutter
## Schermate ## Schermate

View File

@@ -24,13 +24,6 @@ RustDeskは誰からの貢献も歓迎します。 貢献するには [`docs/CON
[**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases) [**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases)
## 無料のパブリックサーバー
下記のサーバーは、無料で使用できますが、後々変更されることがあります。これらのサーバーから遠い場合、接続が遅い可能性があります。
| Location | Vendor | Specification |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## 依存関係 ## 依存関係
デスクトップ版ではGUIに [sciter](https://sciter.com/) が使われています。 sciter dynamic library をダウンロードしてください。 デスクトップ版ではGUIに [sciter](https://sciter.com/) が使われています。 sciter dynamic library をダウンロードしてください。

View File

@@ -24,13 +24,6 @@ RustDesk는 모든 기여를 환영합니다. 기여하고자 한다면 [`docs/C
[**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases) [**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases)
## 무료 퍼블릭 서버
표에 있는 서버는 무료로 사용할 수 있지만 추후 변경될 수도 있습니다. 이 서버에서 멀다면, 네트워크가 느려질 가능성도 있습니다.
| Location | Vendor | Specification |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## 의존관계 ## 의존관계
데스크탑판에는 GUI에 [sciter](https://sciter.com/)가 사용되었습니다. sciter dynamic library 를 다운로드해주세요. 데스크탑판에는 GUI에 [sciter](https://sciter.com/)가 사용되었습니다. sciter dynamic library 를 다운로드해주세요.

View File

@@ -19,13 +19,6 @@
[**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases) [**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases)
## സൗജന്യ പൊതു സെർവറുകൾ
നിങ്ങൾ സൗജന്യമായി ഉപയോഗിക്കുന്ന സെർവറുകൾ ചുവടെയുണ്ട്, അത് സമയത്തിനനുസരിച്ച് മാറിയേക്കാം. നിങ്ങൾ ഇവയിലൊന്നിനോട് അടുത്തല്ലെങ്കിൽ, നിങ്ങളുടെ നെറ്റ്‌വർക്ക് സ്ലോ ആയേക്കാം.
| സ്ഥാനം | കച്ചവടക്കാരൻ | വിവരണം |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## ഡിപെൻഡൻസികൾ ## ഡിപെൻഡൻസികൾ
ഡെസ്‌ക്‌ടോപ്പ് പതിപ്പുകൾ GUI-യ്‌ക്കായി [sciter](https://sciter.com/) ഉപയോഗിക്കുന്നു, ദയവായി സ്‌സൈറ്റർ ഡൈനാമിക് ലൈബ്രറി സ്വയം ഡൗൺലോഡ് ചെയ്യുക. ഡെസ്‌ക്‌ടോപ്പ് പതിപ്പുകൾ GUI-യ്‌ക്കായി [sciter](https://sciter.com/) ഉപയോഗിക്കുന്നു, ദയവായി സ്‌സൈറ്റർ ഡൈനാമിക് ലൈബ്രറി സ്വയം ഡൗൺലോഡ് ചെയ്യുക.

View File

@@ -27,22 +27,6 @@ RustDesk verwelkomt bijdragen van iedereen. Zie [`docs/CONTRIBUTING.md`](CONTRIB
alt="Download het op F-Droid" alt="Download het op F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Gratis openbare servers
Hieronder staan de servers die u gratis gebruikt, ze kunnen in de loop van de tijd veranderen. Als u niet in de buurt van een van deze servers bevindt, kan uw vervinding langzamer zijn.
| Locatie | Aanbieder | Specificaties |
| --------- | ------------- | ------------------ |
| Duitsland | Hetzner | 2 vCPU / 4GB RAM |
| Oekraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dev Container
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Als u VS Code en Docker al hebt geinstalleerd, kunt u op de bovenstaande badge klikken om te beginnen. Door te klikken zal VS Code automatisch de Dev Containers-extensie installeren indien nodig, de broncode klonen naar een containervolume en een dev container opstarten voor gebruik.
Bekijk [DEVCONTAINER.md](docs/DEVCONTAINER.md) voor meer informatie.
## Afhankelijkheden ## Afhankelijkheden
Desktop versies gebruiken [sciter](https://sciter.com/) of Flutter voor GUI, deze handleiding is alleen voor Sciter. Desktop versies gebruiken [sciter](https://sciter.com/) of Flutter voor GUI, deze handleiding is alleen voor Sciter.

View File

@@ -29,22 +29,6 @@ RustDesk zaprasza do współpracy każdego. Zobacz [`docs/CONTRIBUTING-PL.md`](C
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Darmowe Serwery Publiczne
Poniżej znajdują się serwery, z których można korzystać za darmo, może się to zmienić z upływem czasu. Jeśli nie znajdujesz się w pobliżu jednego z nich, Twoja prędkość połączenia może być niska.
| Lokalizacja | Dostawca | Specyfikacja |
| --------- | ------------- | ------------------ |
| Niemcy | Hetzner | 2 vCPU / 4GB RAM |
| Ukraina (Kijów) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Konterner Programisty (Dev Container)
[![Otwórz w Kontenerze programisty](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Jeżeli masz zainstalowany VS Code i Docker, możesz kliknąć w powyższy link, aby rozpocząć. Kliknięcie spowoduje automatyczną instalację rozszrzenia Kontenera Programisty w VS Code (jeżeli wymagany), sklonuje kod źródłowy do kontenera, i przygotuje kontener do użycia.
Więcej informacji w pliku [DEVCONTAINER-PL.md](docs/DEVCONTAINER-PL.md) for more info.
## Zależności ## Zależności
Wersje desktopowe używają [sciter](https://sciter.com/) dla GUI, proszę pobrać samodzielnie bibliotekę sciter. Wersje desktopowe używają [sciter](https://sciter.com/) dla GUI, proszę pobrać samodzielnie bibliotekę sciter.

View File

@@ -19,14 +19,6 @@ RustDesk acolhe contribuições de todos. Leia [`docs/CONTRIBUTING.md`](CONTRIBU
[**DOWNLOAD DE BINÁRIOS**](https://github.com/rustdesk/rustdesk/releases) [**DOWNLOAD DE BINÁRIOS**](https://github.com/rustdesk/rustdesk/releases)
## Servidores Públicos Grátis
Abaixo estão os servidores que você está utilizando de graça, ele pode mudar com o tempo. Se você não está próximo de algum deles, sua conexão pode ser lenta.
| Localização | Fornecedor | Especificações |
| ----------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## Dependências ## Dependências
Versões de desktop utilizam [sciter](https://sciter.com/) para a GUI, por favor baixe a biblioteca dinâmica sciter por conta própria. Versões de desktop utilizam [sciter](https://sciter.com/) para a GUI, por favor baixe a biblioteca dinâmica sciter por conta própria.

View File

@@ -28,13 +28,6 @@ RustDesk приветствует вклад каждого. Ознакомьт
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) [<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Бесплатные общедоступные серверы
Ниже приведены бесплатные публичные сервера, используемые по умолчанию. Имейте ввиду, они могут меняться со временем. Также стоит отметить, что скорость работы сети зависит от вашего местоположения и расстояния до серверов. Подключение происходит к ближайшему доступному.
| Расположение | Поставщик | Технические характеристики |
| --------- | ------------- | ------------------ |
| Германия | Hetzner | 2 vCPU / 4GB RAM |
## Зависимости ## Зависимости
Настольные версии используют [sciter](https://sciter.com/) для графического интерфейса, загрузите динамическую библиотеку sciter самостоятельно. Настольные версии используют [sciter](https://sciter.com/) для графического интерфейса, загрузите динамическую библиотеку sciter самостоятельно.

View File

@@ -30,23 +30,6 @@ RustDesk, herkesten katkıyı kabul eder. Başlamak için [CONTRIBUTING.md](docs
alt="F-Droid'de Alın" alt="F-Droid'de Alın"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Ücretsiz Genel Sunucular
Aşağıda ücretsiz olarak kullandığınız sunucular listelenmiştir, zaman içinde değişebilirler. Eğer bunlardan birine yakın değilseniz, ağınız yavaş olabilir.
| Konum | Sağlayıcı | Özellikler |
| --------- | ------------- | ------------------ |
| Almanya | [Hetzner](https://www.hetzner.com) | 2 vCPU / 4 GB RAM |
| Almanya | [Codext](https://codext.de) | 4 vCPU / 8 GB RAM |
| Ukrayna (Kiev) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4 GB RAM |
## Geliştirici Konteyneri
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Eğer zaten VS Code ve Docker kurulu ise yukarıdaki rozete tıklayarak başlayabilirsiniz. Tıklamak, VS Code'un gerektiğinde Dev Konteyner eklentisini otomatik olarak yüklemesine, kaynak kodunu bir konteyner hacmine klonlamasına ve kullanım için bir geliştirici konteyneri başlatmasına neden olur.
Daha fazla bilgi için [DEVCONTAINER.md](docs/DEVCONTAINER-TR.md) belgesine bakabilirsiniz.
## Bağımlılıklar ## Bağımlılıklar
Masaüstü sürümleri GUI için Masaüstü sürümleri GUI için

View File

@@ -31,22 +31,6 @@ RustDesk вітає внесок кожного. Ознайомтеся з [CONT
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Безкоштовні загальнодоступні сервери
Нижче наведені сервери, для безкоштовного використання, вони можуть змінюватися з часом. Якщо ви не перебуваєте поруч з одним із них, ваша мережа може працювати повільно.
| Місцезнаходження | Постачальник | Технічні характеристики |
| --------- | ------------- | ------------------ |
| Німеччина | [Hetzner](https://www.hetzner.com) | 2 vCPU / 4GB RAM |
| Україна (Київ) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4GB RAM |
## Dev Container
[![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
Якщо у вас уже встановлено VS Code та Docker, ви можете натиснути значок вище, щоб розпочати. Клацання призведе до того, що VS Code автоматично встановить розширення Dev Containers, якщо це необхідно, клонує вихідний код у том контейнера та розгорне контейнер dev для використання.
Дивіться [DEVCONTAINER.md](docs/DEVCONTAINER.md) для додаткової інформації
## Залежності ## Залежності
Стільничні версії використовують Flutter чи Sciter (застаріле) для графічного інтерфейсу. Ця інструкція лише для Sciter, оскільки він є більш простим та дружнім для початківців. Перегляньте [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) для збірки версії на Flutter. Стільничні версії використовують Flutter чи Sciter (застаріле) для графічного інтерфейсу. Ця інструкція лише для Sciter, оскільки він є більш простим та дружнім для початківців. Перегляньте [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) для збірки версії на Flutter.

View File

@@ -1,64 +1,55 @@
<p align="center"> <p align="center">
<img src="../res/logo-header.svg" alt="RustDesk - Phần mềm điểu khiển máy tính từ xa dành cho bạn"><br> <img src="../res/logo-header.svg" alt="RustDesk - Your remote desktop"><br>
<a href="#free-public-servers">Máy chủ</a> • <a href="#free-public-servers">Server</a> •
<a href="#raw-steps-to-build">Build</a> • <a href="#raw-steps-to-build">Build</a> •
<a href="#how-to-build-with-docker">Docker</a> • <a href="#how-to-build-with-docker">Docker</a> •
<a href="#file-structure">Cấu trúc tệp tin</a> • <a href="#file-structure">Structure</a> •
<a href="#snapshot">Snapshot</a><br> <a href="#snapshot">Snapshot</a><br>
[<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-IT.md">Italiano</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-GR.md">Ελληνικά</a>]<br> [<a href="../README.md">English</a>] | [<a href="README-UA.md">Українська</a>] | [<a href="README-CS.md">česky</a>] | [<a href="README-ZH.md">中文</a>] | [<a href="README-HU.md">Magyar</a>] | [<a href="README-ES.md">Español</a>] | [<a href="README-FA.md">فارسی</a>] | [<a href="README-FR.md">Français</a>] | [<a href="README-DE.md">Deutsch</a>] | [<a href="README-PL.md">Polski</a>] | [<a href="README-ID.md">Indonesian</a>] | [<a href="README-FI.md">Suomi</a>] | [<a href="README-ML.md">മലയാളം</a>] | [<a href="README-JP.md">日本語</a>] | [<a href="README-NL.md">Nederlands</a>] | [<a href="README-IT.md">Italiano</a>] | [<a href="README-RU.md">Русский</a>] | [<a href="README-PTBR.md">Português (Brasil)</a>] | [<a href="README-EO.md">Esperanto</a>] | [<a href="README-KR.md">한국어</a>] | [<a href="README-AR.md">العربي</a>] | [<a href="README-GR.md">Ελληνικά</a>]<br>
<b>Chúng tôi cần sự gíup đỡ của bạn để dịch trang README này, <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">RustDesk UI</a> và <a href="https://github.com/rustdesk/doc.rustdesk.com">tài liệu</a> sang ngôn ngữ bản địa của bạn</b> <b>Chúng tôi rất hoan nghênh sự hỗ trợ của bạn trong việc dịch trang README, trang giao diện người dùng của RustDesk - <a href="https://github.com/rustdesk/rustdesk/tree/master/src/lang">RustDesk UI</a> và trang tài liệu của RustDesk - <a href="https://github.com/rustdesk/doc.rustdesk.com">RustDesk Doc</a> sang Tiếng Việt</b>
</p> </p>
Chat với chúng tôi qua: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](https://twitter.com/rustdesk) | [Reddit](https://www.reddit.com/r/rustdesk) Hãy trao đổi với chúng tôi qua: [Discord](https://discord.gg/nDceKgxnkV) | [Twitter](https://twitter.com/rustdesk) | [Reddit](https://www.reddit.com/r/rustdesk)
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I04VU09) [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I04VU09)
Một phần mềm điểu khiển máy tính từ xa, đuợc lập trình bằng ngôn ngữ Rust. Hoạt động tức thì, không cần phải cài đặt. Bạn có toàn quyền điểu khiển với dữ liệu của bạn mà không cần phải lo lắng về sự bảo mật. Bạn có thể sử dụng máy chủ rendezvous/relay của chúng tôi, [tự cài đặt máy chủ](https://rustdesk.com/server), hay thậm chí [tự tạo máy chủ rendezvous/relay](https://github.com/rustdesk/rustdesk-server-demo). RustDesk là một phần mềm điểu khiển máy tính từ xa mã nguồn mở, được viết bằng Rust. Nó hoạt động ngay sau khi cài đặt, không yêu cầu cấu hình phức tạp. Bạn có toàn quyền kiểm soát với dữ liệu của mình mà không cần phải lo lắng về vấn đề bảo mật. Bạn có thể sử dụng máy chủ rendezvous/relay của chúng tôi hoặc [tự cài đặt máy chủ của riêng mình](https://rustdesk.com/server) hay thậm chí [tự tạo máy chủ rendezvous/relay cho riêng bạn](https://github.com/rustdesk/rustdesk-server-demo).
![image](https://user-images.githubusercontent.com/71636191/171661982-430285f0-2e12-4b1d-9957-4a58e375304d.png) ![image](https://user-images.githubusercontent.com/71636191/171661982-430285f0-2e12-4b1d-9957-4a58e375304d.png)
Mọi người đều đuợc chào đón để đóng góp vào RustDesk. Để bắt đầu, hãy đọc [`docs/CONTRIBUTING.md`](CONTRIBUTING.md). **RustDesk** luôn hoan nghênh mọi đóng góp từ mọi người. Hãy xem tệp [`docs/CONTRIBUTING.md`](CONTRIBUTING.md) để bắt đầu.
[**RustDesk hoạt động như thế nào?**](https://github.com/rustdesk/rustdesk/wiki/How-does-RustDesk-work%3F) [**FAQ**](https://github.com/rustdesk/rustdesk/wiki/FAQ)
[**BINARY DOWNLOAD**](https://github.com/rustdesk/rustdesk/releases)
[**CÁC BẢN PHÂN PHÁT MÃ NHỊ PHÂN**](https://github.com/rustdesk/rustdesk/releases) [**NIGHTLY BUILD**](https://github.com/rustdesk/rustdesk/FAQreleases/tag/nightly)
[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" [<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## Các Máy Chủ Công Khai Miễn Phí
Dưới đây là những máy chủ mà bạn có thể sử dụng mà không mất phí, chú ý là máy chủ có thể thay đổi theo thời gian. Nếu địa điểm của bạn không gần một trong số những máy chủ này, thì kết nói có thể chậm.
| Địa điểm | Nhà cung cấp | Cấu hình |
| --------- | ------------- | ------------------ |
| Germany | Hetzner | 2 vCPU / 4GB RAM |
## Dependencies ## Dependencies
Phiên bản cho máy tính sử dụng [sciter](https://sciter.com/) cho giao diện của phần mềm, vậy nên bn cần tự tải về thư viện sciter. Phiên bản máy tính sử dụng __Flutter__ hoặc __Sciter__ (đã lỗi thời) cho giao diện người dùng (GUI). Hướng dẫn này chỉ áp dụng cho phiên bn Sciter, vì nó thân thiện và dễ bắt đầu hơn. Hãy kiểm tra [CI](https://github.com/rustdesk/rustdesk/blob/master/.github/workflows/flutter-build.yml) của chúng tôi để xây dựng phiên bản Flutter.
[Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | Vui lòng tự tải thư viện `Sciter` về máy theo hướng dẫn cho từng hệ điều hành.
[Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) |
[MacOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib)
Phiên bản cho điện thoại sử dụng Flutter. Chúng tôi sẽ chuyển sang sử dụng Flutter thay cho Sciter cho phiên bản máy tính. [Windows](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.win/x64/sciter.dll) | [Linux](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.lnx/x64/libsciter-gtk.so) | [MacOS](https://raw.githubusercontent.com/c-smile/sciter-sdk/master/bin.osx/libsciter.dylib)
## Cách để build ## Các bước build cơ bản
- Chuẩn bị môi trường phát triển Rust và môi trường build C++ - Chuẩn bị môi trường phát triển Rust và môi trường biên dịch C++
- Tải và cài [vcpkg](https://github.com/microsoft/vcpkg), và đặt biến môi trường `VCPKG_ROOT` sao cho đúng. - Tải và cài đặt [`vcpkg`](https://github.com/microsoft/vcpkg), và thiết lập biến môi trường `VCPKG_ROOT`.
- Đối với Windows: vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static
- Đối với Linux/MacOS: vcpkg install libvpx libyuv opus aom
- Windows: `vcpkg install libvpx:x64-windows-static libyuv:x64-windows-static opus:x64-windows-static aom:x64-windows-static`
- Linux/MacOS: `vcpkg install libvpx libyuv opus aom`
- Chạy lệnh `cargo run` - Chạy lệnh `cargo run`
## [Build](https://rustdesk.com/docs/en/dev/build/) ## [Build](https://rustdesk.com/docs/en/dev/build/)
## Cách để build cho Linux ## Cách build cho Linux
### Ubuntu 18 (Debian 10) ### Ubuntu 18 (Debian 10)
@@ -78,7 +69,7 @@ sudo yum -y install gcc-c++ git curl wget nasm yasm gcc gtk3-devel clang libxcb-
sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pipewire sudo pacman -Syu --needed unzip git cmake gcc curl wget yasm nasm zip make pkg-config clang gtk3 xdotool libxcb libxfixes alsa-lib pipewire
``` ```
### Cách cài vcpkg ### Cách cài đặt `vcpkg`
```sh ```sh
git clone https://github.com/microsoft/vcpkg git clone https://github.com/microsoft/vcpkg
@@ -90,7 +81,7 @@ export VCPKG_ROOT=$HOME/vcpkg
vcpkg/vcpkg install libvpx libyuv opus aom vcpkg/vcpkg install libvpx libyuv opus aom
``` ```
### Cách sửa lỗi libvpx (Dành cho hệ điều hành Fedora) ### Cách sửa lỗi `libvpx` (Dành cho hệ điều hành Fedora)
```sh ```sh
cd vcpkg/buildtrees/libvpx/src cd vcpkg/buildtrees/libvpx/src
@@ -103,7 +94,7 @@ cp libvpx.a $HOME/vcpkg/installed/x64-linux/lib/
cd cd
``` ```
### Cách build ### Build
```sh ```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@@ -116,9 +107,9 @@ mv libsciter-gtk.so target/debug
VCPKG_ROOT=$HOME/vcpkg cargo run VCPKG_ROOT=$HOME/vcpkg cargo run
``` ```
## Cách để build sử dụng Docker ## Cách build bằng Docker
Bắt đầu bằng cách sao chép repo này về máy tính và build cái Docker cointainer: Bắt đầu bằng cách sao chép repo này về máy tính của bạn và tạo Docker container:
```sh ```sh
git clone https://github.com/rustdesk/rustdesk git clone https://github.com/rustdesk/rustdesk
@@ -126,37 +117,37 @@ cd rustdesk
docker build -t "rustdesk-builder" . docker build -t "rustdesk-builder" .
``` ```
Rồi mỗi khi bạn chạy ứng dụng, thì hãy chạy lệnh này: Sau đó, mỗi khi bạn chạy ứng dụng, thì hãy chạy dòng lệnh sau:
```sh ```sh
docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder docker run --rm -it -v $PWD:/home/user/rustdesk -v rustdesk-git-cache:/home/user/.cargo/git -v rustdesk-registry-cache:/home/user/.cargo/registry -e PUID="$(id -u)" -e PGID="$(id -g)" rustdesk-builder
``` ```
Chú ý: Lần build đầu tiên có thể sẽ mất lâu hơn truớc khi các dependecies đuợc lưu lại, nhng lần build sau sẽ nhanh hơn. Hơn nũa, nếu bạn cần cung cấp các cài đặt lệnh khác cho lệnh build, bạn có thể đặt những cài đặt lệnh này vào cuối lệnh ở phần `<OPTIONAL-ARGS>`. Ví dụ nếu bạn cần build phiên bản đuợc tối ưu hóa, bạn sẽ chạy lệnh trên cùng với cài đặt lệnh --release. Kết quả build sẽ được lưu trong thư mục target trên máy tính của bạn, và có thể chạy với lệnh: Lưu ý rằng **lần build đầu tiên có thể mất thời gian hơn trước khi các dependencies được lưu vào bộ nhớ cache**, nhưng các lần build sau sẽ nhanh hơn. Ngoài ra, nếu bạn cần chỉ định các đối số khác cho lệnh build, bạn có thể thêm chúng vào cuối lệnh ở phần `<OPTIONAL-ARGS>`. Ví dụ, nếu bạn muốn build phiên bản tối ưu hóa, bạn sẽ chạy lệnh trên với tùy chọn `--release`. Kết quả biên dịch sẽ được lưu trong thư mục target trên máy tính của bạn, và có thể chạy với lệnh:
```sh ```sh
target/debug/rustdesk target/debug/rustdesk
``` ```
Nếu bạn đang chạy bản build đuợc tối ưu hóa, thì bạn có thể chạy với lệnh: Nếu bạn đang chạy bản build được tối ưu hóa, thì bạn có thể chạy với lệnh:
```sh ```sh
target/release/rustdesk target/release/rustdesk
``` ```
Hãy đảm bảo bạn đang chạy những lệnh này từ thu mục rễ của repo RustDesk, vì nếu không thì ứng dụng có thể sẽ không tìm đuợc những tệp tài nguyên cần thiết. Cũng như nhớ rằng những lệnh con của cargo như `install` hoặc `run` hiện chưa được hỗ trợ bởi phương pháp này vì chúng sẽ cài đặt hoặc chạy ứng dụng trong container thay vì trên máy tính của bạn. Hãy đảm bảo rằng bạn đang chạy các lệnh này từ gốc của thư mục **RustDesk**, nếu không, ứng dụng có thể không thể tìm thấy các tệp tài nguyên cần thiết. Hãy lưu ý rằng các câu lệnh con khác của **cargo** như **install** hoặc **run** hiện không được hỗ trợ qua phương pháp này, vì chúng sẽ cài đặt hoặc chạy chương trình bên trong **container** thay vì trên máy tính của bạn.
## Cấu trúc tệp tin ## Cấu trúc tệp tin
- **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: video codec, cấu hình, tcp/udp wrapper, protobuf, fs functions để truyền file, và một số hàm tiện ích khác - **[libs/hbb_common](https://github.com/rustdesk/rustdesk/tree/master/libs/hbb_common)**: video codec, cấu hình, tcp/udp wrapper, protobuf, fs functions để truyền file, và một số hàm tiện ích khác
- **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: để ghi lại màn hình - **[libs/scrap](https://github.com/rustdesk/rustdesk/tree/master/libs/scrap)**: ghi lại màn hình
- **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: để điều khiển máy tính/con chuột trên những nền tảng khác nhau - **[libs/enigo](https://github.com/rustdesk/rustdesk/tree/master/libs/enigo)**: điều khiển máy tính/chuột trên các nền tảng khác nhau
- **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: giao diện người dùng - **[src/ui](https://github.com/rustdesk/rustdesk/tree/master/src/ui)**: giao diện người dùng
- **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: các dịch vụ âm thanh, clipboard, đầu vào, video và các kết nối mạng - **[src/server](https://github.com/rustdesk/rustdesk/tree/master/src/server)**: các dịch vụ âm thanh, clipboard, đầu vào, video và các kết nối mạng
- **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: để bắt đầu kết nối với một peer - **[src/client.rs](https://github.com/rustdesk/rustdesk/tree/master/src/client.rs)**: bắt đầu kết nối với một peer
- **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: Để liên lạc với [rustdesk-server](https://github.com/rustdesk/rustdesk-server), đợi cho kết nối trực tiếp (TCP hole punching) hoặc kết nối được relayed. - **[src/rendezvous_mediator.rs](https://github.com/rustdesk/rustdesk/tree/master/src/rendezvous_mediator.rs)**: giao tiếp với [rustdesk-server](https://github.com/rustdesk/rustdesk-server), đợi kết nối trực tiếp (TCP hole punching) hoặc kết nối được chuyển tiếp.
- **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: mã nguồn riêng cho mỗi nền tảng - **[src/platform](https://github.com/rustdesk/rustdesk/tree/master/src/platform)**: mã nguồn riêng cho mỗi nền tảng
- **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: Mã Flutter dành cho điện thoại - **[flutter](https://github.com/rustdesk/rustdesk/tree/master/flutter)**: Mã Flutter dành máy tính và điện thoại
- **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/js)**: Mã JavaScript dành cho giao diện trên web bằng Flutter - **[flutter/web/js](https://github.com/rustdesk/rustdesk/tree/master/flutter/web/js)**: Mã JavaScript dành cho giao diện trên web bằng Flutter
## Snapshot ## Snapshot

View File

@@ -30,23 +30,6 @@ RustDesk 期待各位的贡献. 如何参与开发? 详情请看 [CONTRIBUTING.m
alt="Get it on F-Droid" alt="Get it on F-Droid"
height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb) height="80">](https://f-droid.org/en/packages/com.carriez.flutter_hbb)
## 免费的公共服务器
以下是您可以使用的、免费的、会随时更新的公共服务器列表,在国内也许网速会很慢或者无法访问。
| Location | Vendor | Specification |
| --------- | ------------- | ------------------ |
| Germany | [Hetzner](https://www.hetzner.com) | 2 vCPU / 4 GB RAM |
| Ukraine (Kyiv) | [dc.volia](https://dc.volia.com) | 2 vCPU / 4 GB RAM |
## Dev Container
[![在 Dev Containers 中打开](https://img.shields.io/static/v1?label=Dev%20Container&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/rustdesk/rustdesk)
如果你已经安装了 VS Code 和 Docker, 你可以点击上面的徽章开始使用. 点击后, VS Code 将自动安装 Dev Containers 扩展(如果需要),将源代码克隆到容器卷中, 并启动一个 Dev 容器供使用.
Go through [DEVCONTAINER.md](docs/DEVCONTAINER.md) for more info.
## 依赖 ## 依赖
桌面版本界面使用[sciter](https://sciter.com/), 请自行下载。 桌面版本界面使用[sciter](https://sciter.com/), 请自行下载。

View File

@@ -8,29 +8,43 @@
"modules": [ "modules": [
"shared-modules/libappindicator/libappindicator-gtk3-12.10.json", "shared-modules/libappindicator/libappindicator-gtk3-12.10.json",
"xdotool.json", "xdotool.json",
{
"name": "pam",
"buildsystem": "simple",
"build-commands": [
"./configure --disable-selinux --prefix=/app && make -j4 install"
],
"sources": [
{
"type": "archive",
"url": "https://github.com/linux-pam/linux-pam/releases/download/v1.3.1/Linux-PAM-1.3.1.tar.xz",
"sha256": "eff47a4ecd833fbf18de9686632a70ee8d0794b79aecb217ebd0ce11db4cd0db"
}
]
},
{ {
"name": "rustdesk", "name": "rustdesk",
"buildsystem": "simple", "buildsystem": "simple",
"build-commands": [ "build-commands": [
"bsdtar -zxvf rustdesk-1.2.4.deb", "bsdtar -zxvf rustdesk.deb",
"tar -xvf ./data.tar.xz", "tar -xvf ./data.tar.xz",
"cp -r ./usr/* /app/", "cp -r ./usr/* /app/",
"mkdir -p /app/bin && ln -s /app/lib/rustdesk/rustdesk /app/bin/rustdesk", "mkdir -p /app/bin && ln -s /app/lib/rustdesk/rustdesk /app/bin/rustdesk",
"mv /app/share/applications/rustdesk.desktop /app/share/applications/com.rustdesk.RustDesk.desktop", "mv /app/share/applications/rustdesk.desktop /app/share/applications/com.rustdesk.RustDesk.desktop",
"sed -i '/^Icon=/ c\\Icon=com.rustdesk.RustDesk' /app/share/applications/com.rustdesk.RustDesk.desktop", "mv /app/share/applications/rustdesk-link.desktop /app/share/applications/com.rustdesk.RustDesk-link.desktop",
"sed -i '/^Icon=/ c\\Icon=com.rustdesk.RustDesk' /app/share/applications/rustdesk-link.desktop", "sed -i '/^Icon=/ c\\Icon=com.rustdesk.RustDesk' /app/share/applications/*.desktop",
"mv /app/share/icons/hicolor/scalable/apps/rustdesk.svg /app/share/icons/hicolor/scalable/apps/com.rustdesk.RustDesk.svg", "mv /app/share/icons/hicolor/scalable/apps/rustdesk.svg /app/share/icons/hicolor/scalable/apps/com.rustdesk.RustDesk.svg",
"for size in 16 24 32 48 64 128 256 512; do\n rsvg-convert -w $size -h $size -f png -o $size.png logo.svg\n install -Dm644 $size.png /app/share/icons/hicolor/${size}x${size}/apps/com.rustdesk.RustDesk.png\n done" "for size in 16 24 32 48 64 128 256 512; do\n rsvg-convert -w $size -h $size -f png -o $size.png scalable.svg\n install -Dm644 $size.png /app/share/icons/hicolor/${size}x${size}/apps/com.rustdesk.RustDesk.png\n done"
], ],
"cleanup": ["/include", "/lib/pkgconfig", "/share/gtk-doc"], "cleanup": ["/include", "/lib/pkgconfig", "/share/gtk-doc"],
"sources": [ "sources": [
{ {
"type": "file", "type": "file",
"path": "../rustdesk-1.2.4.deb" "path": "./rustdesk.deb"
}, },
{ {
"type": "file", "type": "file",
"path": "../res/logo.svg" "path": "../res/scalable.svg"
} }
] ]
} }

1
flutter/.gitignore vendored
View File

@@ -32,7 +32,6 @@
/build/ /build/
# Web related # Web related
lib/generated_plugin_registrant.dart
# Symbolication related # Symbolication related
app.*.symbols app.*.symbols

View File

@@ -108,4 +108,3 @@ dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib") { version { strictly("$kotlin_version") } } implementation("org.jetbrains.kotlin:kotlin-stdlib") { version { strictly("$kotlin_version") } }
} }
apply plugin: 'com.google.gms.google-services'

View File

@@ -1,40 +0,0 @@
{
"project_info": {
"project_number": "768133699366",
"firebase_url": "https://rustdesk.firebaseio.com",
"project_id": "rustdesk",
"storage_bucket": "rustdesk.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:768133699366:android:5fc9015370e344457993e7",
"android_client_info": {
"package_name": "com.carriez.flutter_hbb"
}
},
"oauth_client": [
{
"client_id": "768133699366-s9gdfsijefsd5g1nura4kmfne42lencn.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAPOsKcXjrAR-7Z148sYr_gdB_JQZkamTM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "768133699366-s9gdfsijefsd5g1nura4kmfne42lencn.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View File

@@ -3,6 +3,7 @@
package="com.carriez.flutter_hbb"> package="com.carriez.flutter_hbb">
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

View File

@@ -1,5 +1,7 @@
package com.carriez.flutter_hbb package com.carriez.flutter_hbb
import ffi.FFI
/** /**
* Capture screen,get video and audio,send to rust. * Capture screen,get video and audio,send to rust.
* Dispatch notifications * Dispatch notifications
@@ -52,7 +54,6 @@ const val NOTIFY_ID_OFFSET = 100
const val MIME_TYPE = MediaFormat.MIMETYPE_VIDEO_VP9 const val MIME_TYPE = MediaFormat.MIMETYPE_VIDEO_VP9
// video const // video const
const val MAX_SCREEN_SIZE = 1200
const val VIDEO_KEY_BIT_RATE = 1024_000 const val VIDEO_KEY_BIT_RATE = 1024_000
const val VIDEO_KEY_FRAME_RATE = 30 const val VIDEO_KEY_FRAME_RATE = 30
@@ -64,10 +65,6 @@ const val AUDIO_CHANNEL_MASK = AudioFormat.CHANNEL_IN_STEREO
class MainService : Service() { class MainService : Service() {
init {
System.loadLibrary("rustdesk")
}
@Keep @Keep
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun rustPointerInput(kind: String, mask: Int, x: Int, y: Int) { fun rustPointerInput(kind: String, mask: Int, x: Int, y: Int) {
@@ -156,23 +153,9 @@ class MainService : Service() {
private val powerManager: PowerManager by lazy { applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager } private val powerManager: PowerManager by lazy { applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager }
private val wakeLock: PowerManager.WakeLock by lazy { powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "rustdesk:wakelock")} private val wakeLock: PowerManager.WakeLock by lazy { powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "rustdesk:wakelock")}
// jvm call rust
private external fun init(ctx: Context)
/// When app start on boot, app_dir will not be passed from flutter
/// so pass a app_dir here to rust server
private external fun startServer(app_dir: String)
private external fun startService()
private external fun onVideoFrameUpdate(buf: ByteBuffer)
private external fun onAudioFrameUpdate(buf: ByteBuffer)
private external fun translateLocale(localeName: String, input: String): String
private external fun refreshScreen()
private external fun setFrameRawEnable(name: String, value: Boolean)
// private external fun sendVp9(data: ByteArray)
private fun translate(input: String): String { private fun translate(input: String): String {
Log.d(logTag, "translate:$LOCAL_NAME") Log.d(logTag, "translate:$LOCAL_NAME")
return translateLocale(LOCAL_NAME, input) return FFI.translateLocale(LOCAL_NAME, input)
} }
companion object { companion object {
@@ -188,6 +171,7 @@ class MainService : Service() {
private val useVP9 = false private val useVP9 = false
private val binder = LocalBinder() private val binder = LocalBinder()
private var reuseVirtualDisplay = Build.VERSION.SDK_INT > 33
// video // video
private var mediaProjection: MediaProjection? = null private var mediaProjection: MediaProjection? = null
@@ -210,8 +194,8 @@ class MainService : Service() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
Log.d(logTag,"MainService onCreate") Log.d(logTag,"MainService onCreate, sdk int:${Build.VERSION.SDK_INT} reuseVirtualDisplay:$reuseVirtualDisplay")
init(this) FFI.init(this)
HandlerThread("Service", Process.THREAD_PRIORITY_BACKGROUND).apply { HandlerThread("Service", Process.THREAD_PRIORITY_BACKGROUND).apply {
start() start()
serviceLooper = looper serviceLooper = looper
@@ -223,7 +207,7 @@ class MainService : Service() {
// keep the config dir same with flutter // keep the config dir same with flutter
val prefs = applicationContext.getSharedPreferences(KEY_SHARED_PREFERENCES, FlutterActivity.MODE_PRIVATE) val prefs = applicationContext.getSharedPreferences(KEY_SHARED_PREFERENCES, FlutterActivity.MODE_PRIVATE)
val configPath = prefs.getString(KEY_APP_DIR_CONFIG_PATH, "") ?: "" val configPath = prefs.getString(KEY_APP_DIR_CONFIG_PATH, "") ?: ""
startServer(configPath) FFI.startServer(configPath, "")
createForegroundNotification() createForegroundNotification()
} }
@@ -265,12 +249,6 @@ class MainService : Service() {
Log.d(logTag,"updateScreenInfo:w:$w,h:$h") Log.d(logTag,"updateScreenInfo:w:$w,h:$h")
var scale = 1 var scale = 1
if (w != 0 && h != 0) { if (w != 0 && h != 0) {
if (w > MAX_SCREEN_SIZE || h > MAX_SCREEN_SIZE) {
scale = 2
w /= scale
h /= scale
dpi /= scale
}
if (SCREEN_INFO.width != w) { if (SCREEN_INFO.width != w) {
SCREEN_INFO.width = w SCREEN_INFO.width = w
SCREEN_INFO.height = h SCREEN_INFO.height = h
@@ -278,7 +256,7 @@ class MainService : Service() {
SCREEN_INFO.dpi = dpi SCREEN_INFO.dpi = dpi
if (isStart) { if (isStart) {
stopCapture() stopCapture()
refreshScreen() FFI.refreshScreen()
startCapture() startCapture()
} }
} }
@@ -306,7 +284,7 @@ class MainService : Service() {
createForegroundNotification() createForegroundNotification()
if (intent.getBooleanExtra(EXT_INIT_FROM_BOOT, false)) { if (intent.getBooleanExtra(EXT_INIT_FROM_BOOT, false)) {
startService() FFI.startService()
} }
Log.d(logTag, "service starting: ${startId}:${Thread.currentThread()}") Log.d(logTag, "service starting: ${startId}:${Thread.currentThread()}")
val mediaProjectionManager = val mediaProjectionManager =
@@ -354,12 +332,13 @@ class MainService : Service() {
).apply { ).apply {
setOnImageAvailableListener({ imageReader: ImageReader -> setOnImageAvailableListener({ imageReader: ImageReader ->
try { try {
// If not call acquireLatestImage, listener will not be called again
imageReader.acquireLatestImage().use { image -> imageReader.acquireLatestImage().use { image ->
if (image == null) return@setOnImageAvailableListener if (image == null || !isStart) return@setOnImageAvailableListener
val planes = image.planes val planes = image.planes
val buffer = planes[0].buffer val buffer = planes[0].buffer
buffer.rewind() buffer.rewind()
onVideoFrameUpdate(buffer) FFI.onVideoFrameUpdate(buffer)
} }
} catch (ignored: java.lang.Exception) { } catch (ignored: java.lang.Exception) {
} }
@@ -378,6 +357,7 @@ class MainService : Service() {
Log.w(logTag, "startCapture fail,mediaProjection is null") Log.w(logTag, "startCapture fail,mediaProjection is null")
return false return false
} }
updateScreenInfo(resources.configuration.orientation) updateScreenInfo(resources.configuration.orientation)
Log.d(logTag, "Start Capture") Log.d(logTag, "Start Capture")
surface = createSurface() surface = createSurface()
@@ -393,34 +373,45 @@ class MainService : Service() {
} }
checkMediaPermission() checkMediaPermission()
_isStart = true _isStart = true
setFrameRawEnable("video",true) FFI.setFrameRawEnable("video",true)
setFrameRawEnable("audio",true) FFI.setFrameRawEnable("audio",true)
return true return true
} }
@Synchronized @Synchronized
fun stopCapture() { fun stopCapture() {
Log.d(logTag, "Stop Capture") Log.d(logTag, "Stop Capture")
setFrameRawEnable("video",false) FFI.setFrameRawEnable("video",false)
setFrameRawEnable("audio",false) FFI.setFrameRawEnable("audio",false)
_isStart = false _isStart = false
// release video // release video
virtualDisplay?.release() if (reuseVirtualDisplay) {
surface?.release() // The virtual display video projection can be paused by calling `setSurface(null)`.
// https://developer.android.com/reference/android/hardware/display/VirtualDisplay.Callback
// https://learn.microsoft.com/en-us/dotnet/api/android.hardware.display.virtualdisplay.callback.onpaused?view=net-android-34.0
virtualDisplay?.setSurface(null)
} else {
virtualDisplay?.release()
}
// suface needs to be release after `imageReader.close()` to imageReader access released surface
// https://github.com/rustdesk/rustdesk/issues/4118#issuecomment-1515666629
imageReader?.close() imageReader?.close()
imageReader = null
videoEncoder?.let { videoEncoder?.let {
it.signalEndOfInputStream() it.signalEndOfInputStream()
it.stop() it.stop()
it.release() it.release()
} }
virtualDisplay = null if (!reuseVirtualDisplay) {
virtualDisplay = null
}
videoEncoder = null videoEncoder = null
// suface needs to be release after `imageReader.close()` to imageReader access released surface
// https://github.com/rustdesk/rustdesk/issues/4118#issuecomment-1515666629
surface?.release()
// release audio // release audio
audioRecordStat = false audioRecordStat = false
audioRecorder?.release()
audioRecorder = null
minBufferSize = 0
} }
fun destroy() { fun destroy() {
@@ -428,8 +419,11 @@ class MainService : Service() {
_isReady = false _isReady = false
stopCapture() stopCapture()
imageReader?.close()
imageReader = null if (reuseVirtualDisplay) {
virtualDisplay?.release()
virtualDisplay = null
}
mediaProjection = null mediaProjection = null
checkMediaPermission() checkMediaPermission()
@@ -459,11 +453,7 @@ class MainService : Service() {
Log.d(logTag, "startRawVideoRecorder failed,surface is null") Log.d(logTag, "startRawVideoRecorder failed,surface is null")
return return
} }
virtualDisplay = mp.createVirtualDisplay( createOrSetVirtualDisplay(mp, surface!!)
"RustDeskVD",
SCREEN_INFO.width, SCREEN_INFO.height, SCREEN_INFO.dpi, VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
surface, null, null
)
} }
private fun startVP9VideoRecorder(mp: MediaProjection) { private fun startVP9VideoRecorder(mp: MediaProjection) {
@@ -475,11 +465,28 @@ class MainService : Service() {
} }
it.setCallback(cb) it.setCallback(cb)
it.start() it.start()
virtualDisplay = mp.createVirtualDisplay( createOrSetVirtualDisplay(mp, surface!!)
"RustDeskVD", }
SCREEN_INFO.width, SCREEN_INFO.height, SCREEN_INFO.dpi, VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, }
surface, null, null
) // https://github.com/bk138/droidVNC-NG/blob/b79af62db5a1c08ed94e6a91464859ffed6f4e97/app/src/main/java/net/christianbeier/droidvnc_ng/MediaProjectionService.java#L250
// Reuse virtualDisplay if it exists, to avoid media projection confirmation dialog every connection.
private fun createOrSetVirtualDisplay(mp: MediaProjection, s: Surface) {
try {
virtualDisplay?.let {
it.resize(SCREEN_INFO.width, SCREEN_INFO.height, SCREEN_INFO.dpi)
it.setSurface(s)
} ?: let {
virtualDisplay = mp.createVirtualDisplay(
"RustDeskVD",
SCREEN_INFO.width, SCREEN_INFO.height, SCREEN_INFO.dpi, VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
s, null, null
)
}
} catch (e: SecurityException) {
Log.w(logTag, "createOrSetVirtualDisplay: got SecurityException, re-requesting confirmation");
// This initiates a prompt dialog for the user to confirm screen projection.
requestMediaProjection()
} }
} }
@@ -537,9 +544,13 @@ class MainService : Service() {
thread { thread {
while (audioRecordStat) { while (audioRecordStat) {
audioReader!!.readSync(audioRecorder!!)?.let { audioReader!!.readSync(audioRecorder!!)?.let {
onAudioFrameUpdate(it) FFI.onAudioFrameUpdate(it)
} }
} }
// let's release here rather than onDestroy to avoid threading issue
audioRecorder?.release()
audioRecorder = null
minBufferSize = 0
Log.d(logTag, "Exit audio thread") Log.d(logTag, "Exit audio thread")
} }
} catch (e: Exception) { } catch (e: Exception) {

View File

@@ -0,0 +1,21 @@
// ffi.kt
package ffi
import android.content.Context
import java.nio.ByteBuffer
object FFI {
init {
System.loadLibrary("rustdesk")
}
external fun init(ctx: Context)
external fun startServer(app_dir: String, custom_client_config: String)
external fun startService()
external fun onVideoFrameUpdate(buf: ByteBuffer)
external fun onAudioFrameUpdate(buf: ByteBuffer)
external fun translateLocale(localeName: String, input: String): String
external fun refreshScreen()
external fun setFrameRawEnable(name: String, value: Boolean)
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" class="icon" viewBox="0 0 1024 1024"><path d="M608 160c141.16 0 256 114.84 256 256 0 17.67 14.33 32 32 32s32-14.33 32-32c0-85.48-33.29-165.83-93.73-226.27C773.83 129.29 693.47 96 608 96c-17.67 0-32 14.33-32 32s14.33 32 32 32zm-24 168c61.76 0 112 50.24 112 112 0 17.67 14.33 32 32 32s32-14.33 32-32c0-97.05-78.95-176-176-176-17.67 0-32 14.33-32 32s14.33 32 32 32z"/><path d="M808.3 561.21c-12.76-3.83-25.7-6.2-38.46-7.03-60.3-4.5-116.45 18.9-146.55 61.08-22.6 31.67-45.66 50.01-68.52 54.5-17.71 3.48-33.12-1.7-45.49-5.85-2.66-.9-5.18-1.74-7.68-2.49-93.84-28.17-156.49-108.42-155.9-199.7.16-24.14 16.38-45.98 42.34-56.99 43.75-18.56 77.35-54 92.17-97.22 7.02-20.48 9.65-41.57 7.8-62.68-2.66-31.78-15.1-61.85-35.96-86.96-21.1-25.39-49.51-44-82.16-53.8-4.07-1.22-8.22-2.31-12.35-3.23-30.63-6.87-62.7-4.49-92.73 6.88-29.24 11.07-54.56 29.86-73.23 54.33a476.073 476.073 0 0 0-36.42 55.34 477.675 477.675 0 0 0-17.24 33.81C109.84 312.17 95.73 376.76 96 443.15c.26 63.78 13.7 126.26 39.95 185.7 27.55 62.39 69.3 119.84 120.74 166.11 54.14 48.71 117.6 84.85 188.63 107.4C499.02 919.41 554.33 928 610.21 928c10.99 0 22.01-.33 33.03-1 17.64-1.07 31.08-16.23 30.01-33.87-1.07-17.64-16.22-31.08-33.87-30.01-59.19 3.57-117.96-3.75-174.69-21.76C342.78 802.66 244.31 715.78 194.5 603c-46.76-105.9-46.21-221.33 1.55-325.03 4.55-9.87 9.57-19.72 14.92-29.26 9.29-16.54 19.89-32.64 31.5-47.86 23.47-30.77 64.09-45.87 101.07-37.58 2.66.6 5.33 1.3 7.95 2.08 40.93 12.29 69.48 45.6 72.75 84.86 0 .05.01.1.01.15 1.07 12.15-.47 24.39-4.58 36.37-8.94 26.06-29.58 47.59-56.63 59.07-23.58 10.01-43.63 25.72-57.99 45.45-15.12 20.78-23.2 45-23.36 70.05-.37 57.15 19 114.29 54.53 160.91 36.46 47.83 87.28 82.58 146.96 100.49 1.5.45 3.44 1.1 5.69 1.86 29.79 10.01 108.9 36.59 186.49-72.13 16.95-23.75 52.2-37.26 89.81-34.42l.36.03c7.97.51 16.17 2.02 24.34 4.47 22.12 6.64 42.04 25.38 56.11 52.77 16.97 33.04 21.71 72.53 12.1 100.56l-.16.47c-5.54 16.05-17.78 29.48-34.47 37.8-15.82 7.89-22.24 27.1-14.36 42.92s27.1 22.24 42.92 14.36c31.78-15.85 55.36-42.19 66.41-74.2l.18-.53c15.23-44.4 9.22-102.11-15.68-150.61-22.07-43.02-55.68-73.15-94.62-84.84z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" class="icon" viewBox="-186 -186 1365 1365"><path d="M608 160c141.16 0 256 114.84 256 256 0 17.67 14.33 32 32 32s32-14.33 32-32c0-85.48-33.29-165.83-93.73-226.27C773.83 129.29 693.47 96 608 96c-17.67 0-32 14.33-32 32s14.33 32 32 32zm-24 168c61.76 0 112 50.24 112 112 0 17.67 14.33 32 32 32s32-14.33 32-32c0-97.05-78.95-176-176-176-17.67 0-32 14.33-32 32s14.33 32 32 32z"/><path d="M808.3 561.21c-12.76-3.83-25.7-6.2-38.46-7.03-60.3-4.5-116.45 18.9-146.55 61.08-22.6 31.67-45.66 50.01-68.52 54.5-17.71 3.48-33.12-1.7-45.49-5.85-2.66-.9-5.18-1.74-7.68-2.49-93.84-28.17-156.49-108.42-155.9-199.7.16-24.14 16.38-45.98 42.34-56.99 43.75-18.56 77.35-54 92.17-97.22 7.02-20.48 9.65-41.57 7.8-62.68-2.66-31.78-15.1-61.85-35.96-86.96-21.1-25.39-49.51-44-82.16-53.8-4.07-1.22-8.22-2.31-12.35-3.23-30.63-6.87-62.7-4.49-92.73 6.88-29.24 11.07-54.56 29.86-73.23 54.33a476.073 476.073 0 0 0-36.42 55.34 477.675 477.675 0 0 0-17.24 33.81C109.84 312.17 95.73 376.76 96 443.15c.26 63.78 13.7 126.26 39.95 185.7 27.55 62.39 69.3 119.84 120.74 166.11 54.14 48.71 117.6 84.85 188.63 107.4C499.02 919.41 554.33 928 610.21 928c10.99 0 22.01-.33 33.03-1 17.64-1.07 31.08-16.23 30.01-33.87-1.07-17.64-16.22-31.08-33.87-30.01-59.19 3.57-117.96-3.75-174.69-21.76C342.78 802.66 244.31 715.78 194.5 603c-46.76-105.9-46.21-221.33 1.55-325.03 4.55-9.87 9.57-19.72 14.92-29.26 9.29-16.54 19.89-32.64 31.5-47.86 23.47-30.77 64.09-45.87 101.07-37.58 2.66.6 5.33 1.3 7.95 2.08 40.93 12.29 69.48 45.6 72.75 84.86 0 .05.01.1.01.15 1.07 12.15-.47 24.39-4.58 36.37-8.94 26.06-29.58 47.59-56.63 59.07-23.58 10.01-43.63 25.72-57.99 45.45-15.12 20.78-23.2 45-23.36 70.05-.37 57.15 19 114.29 54.53 160.91 36.46 47.83 87.28 82.58 146.96 100.49 1.5.45 3.44 1.1 5.69 1.86 29.79 10.01 108.9 36.59 186.49-72.13 16.95-23.75 52.2-37.26 89.81-34.42l.36.03c7.97.51 16.17 2.02 24.34 4.47 22.12 6.64 42.04 25.38 56.11 52.77 16.97 33.04 21.71 72.53 12.1 100.56l-.16.47c-5.54 16.05-17.78 29.48-34.47 37.8-15.82 7.89-22.24 27.1-14.36 42.92s27.1 22.24 42.92 14.36c31.78-15.85 55.36-42.19 66.41-74.2l.18-.53c15.23-44.4 9.22-102.11-15.68-150.61-22.07-43.02-55.68-73.15-94.62-84.84z"/></svg>

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -139,4 +139,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: d4cb12ad5d3bdb3352770b1d3db237584e155156 PODFILE CHECKSUM: d4cb12ad5d3bdb3352770b1d3db237584e155156
COCOAPODS: 1.12.1 COCOAPODS: 1.15.2

View File

@@ -159,7 +159,7 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1430; LastUpgradeCheck = 1510;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
97C146ED1CF9000F007C117D = { 97C146ED1CF9000F007C117D = {

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1430" LastUpgradeVersion = "1510"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"

View File

@@ -1,12 +1,9 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:ffi' hide Size;
import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:back_button_interceptor/back_button_interceptor.dart'; import 'package:back_button_interceptor/back_button_interceptor.dart';
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:ffi/ffi.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -25,7 +22,6 @@ import 'package:get/get.dart';
import 'package:uni_links/uni_links.dart'; import 'package:uni_links/uni_links.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'package:win32/win32.dart' as win32;
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
import 'package:window_size/window_size.dart' as window_size; import 'package:window_size/window_size.dart' as window_size;
@@ -33,22 +29,38 @@ import '../consts.dart';
import 'common/widgets/overlay.dart'; import 'common/widgets/overlay.dart';
import 'mobile/pages/file_manager_page.dart'; import 'mobile/pages/file_manager_page.dart';
import 'mobile/pages/remote_page.dart'; import 'mobile/pages/remote_page.dart';
import 'desktop/pages/remote_page.dart' as desktop_remote;
import 'package:flutter_hbb/desktop/widgets/remote_toolbar.dart';
import 'models/input_model.dart'; import 'models/input_model.dart';
import 'models/model.dart'; import 'models/model.dart';
import 'models/platform_model.dart'; import 'models/platform_model.dart';
import 'package:flutter_hbb/native/win32.dart'
if (dart.library.html) 'package:flutter_hbb/web/win32.dart';
import 'package:flutter_hbb/native/common.dart'
if (dart.library.html) 'package:flutter_hbb/web/common.dart';
final globalKey = GlobalKey<NavigatorState>(); final globalKey = GlobalKey<NavigatorState>();
final navigationBarKey = GlobalKey(); final navigationBarKey = GlobalKey();
final isAndroid = Platform.isAndroid; final isAndroid = isAndroid_;
final isIOS = Platform.isIOS; final isIOS = isIOS_;
final isDesktop = Platform.isWindows || Platform.isMacOS || Platform.isLinux; final isWindows = isWindows_;
var isWeb = false; final isMacOS = isMacOS_;
var isWebDesktop = false; final isLinux = isLinux_;
final isDesktop = isDesktop_;
final isWeb = isWeb_;
final isWebDesktop = isWebDesktop_;
var isMobile = isAndroid || isIOS; var isMobile = isAndroid || isIOS;
var version = ""; var version = '';
int androidVersion = 0; int androidVersion = 0;
// Only used on Linux.
// `windowManager.setResizable(false)` will reset the window size to the default size on Linux.
// https://stackoverflow.com/questions/8193613/gtk-window-resize-disable-without-going-back-to-default
// So we need to use this flag to enable/disable resizable.
bool _linuxWindowResizable = true;
/// only available for Windows target /// only available for Windows target
int windowsBuildNumber = 0; int windowsBuildNumber = 0;
DesktopType? desktopType; DesktopType? desktopType;
@@ -56,6 +68,8 @@ DesktopType? desktopType;
bool get isMainDesktopWindow => bool get isMainDesktopWindow =>
desktopType == DesktopType.main || desktopType == DesktopType.cm; desktopType == DesktopType.main || desktopType == DesktopType.cm;
String get screenInfo => screenInfo_;
/// Check if the app is running with single view mode. /// Check if the app is running with single view mode.
bool isSingleViewApp() { bool isSingleViewApp() {
return desktopType == DesktopType.cm; return desktopType == DesktopType.cm;
@@ -229,11 +243,13 @@ class MyTheme {
); );
static SwitchThemeData switchTheme() { static SwitchThemeData switchTheme() {
return SwitchThemeData(splashRadius: isDesktop ? 0 : kRadialReactionRadius); return SwitchThemeData(
splashRadius: (isDesktop || isWebDesktop) ? 0 : kRadialReactionRadius);
} }
static RadioThemeData radioTheme() { static RadioThemeData radioTheme() {
return RadioThemeData(splashRadius: isDesktop ? 0 : kRadialReactionRadius); return RadioThemeData(
splashRadius: (isDesktop || isWebDesktop) ? 0 : kRadialReactionRadius);
} }
// Checkbox // Checkbox
@@ -282,7 +298,7 @@ class MyTheme {
static EdgeInsets dialogContentPadding({bool actions = true}) { static EdgeInsets dialogContentPadding({bool actions = true}) {
final double p = dialogPadding; final double p = dialogPadding;
return isDesktop return (isDesktop || isWebDesktop)
? EdgeInsets.fromLTRB(p, p, p, actions ? (p - 4) : p) ? EdgeInsets.fromLTRB(p, p, p, actions ? (p - 4) : p)
: EdgeInsets.fromLTRB(p, p, p, actions ? (p / 2) : p); : EdgeInsets.fromLTRB(p, p, p, actions ? (p / 2) : p);
} }
@@ -290,12 +306,12 @@ class MyTheme {
static EdgeInsets dialogActionsPadding() { static EdgeInsets dialogActionsPadding() {
final double p = dialogPadding; final double p = dialogPadding;
return isDesktop return (isDesktop || isWebDesktop)
? EdgeInsets.fromLTRB(p, 0, p, (p - 4)) ? EdgeInsets.fromLTRB(p, 0, p, (p - 4))
: EdgeInsets.fromLTRB(p, 0, (p - mobileTextButtonPaddingLR), (p / 2)); : EdgeInsets.fromLTRB(p, 0, (p - mobileTextButtonPaddingLR), (p / 2));
} }
static EdgeInsets dialogButtonPadding = isDesktop static EdgeInsets dialogButtonPadding = (isDesktop || isWebDesktop)
? EdgeInsets.only(left: dialogPadding) ? EdgeInsets.only(left: dialogPadding)
: EdgeInsets.only(left: dialogPadding / 3); : EdgeInsets.only(left: dialogPadding / 3);
@@ -367,10 +383,10 @@ class MyTheme {
labelColor: Colors.black87, labelColor: Colors.black87,
), ),
tooltipTheme: tooltipTheme(), tooltipTheme: tooltipTheme(),
splashColor: isDesktop ? Colors.transparent : null, splashColor: (isDesktop || isWebDesktop) ? Colors.transparent : null,
highlightColor: isDesktop ? Colors.transparent : null, highlightColor: (isDesktop || isWebDesktop) ? Colors.transparent : null,
splashFactory: isDesktop ? NoSplash.splashFactory : null, splashFactory: (isDesktop || isWebDesktop) ? NoSplash.splashFactory : null,
textButtonTheme: isDesktop textButtonTheme: (isDesktop || isWebDesktop)
? TextButtonThemeData( ? TextButtonThemeData(
style: TextButton.styleFrom( style: TextButton.styleFrom(
splashFactory: NoSplash.splashFactory, splashFactory: NoSplash.splashFactory,
@@ -410,7 +426,9 @@ class MyTheme {
color: Colors.white, color: Colors.white,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
side: BorderSide( side: BorderSide(
color: isDesktop ? Color(0xFFECECEC) : Colors.transparent), color: (isDesktop || isWebDesktop)
? Color(0xFFECECEC)
: Colors.transparent),
borderRadius: BorderRadius.all(Radius.circular(8.0)), borderRadius: BorderRadius.all(Radius.circular(8.0)),
)), )),
).copyWith( ).copyWith(
@@ -436,7 +454,7 @@ class MyTheme {
), ),
), ),
scrollbarTheme: scrollbarThemeDark, scrollbarTheme: scrollbarThemeDark,
inputDecorationTheme: isDesktop inputDecorationTheme: (isDesktop || isWebDesktop)
? InputDecorationTheme( ? InputDecorationTheme(
fillColor: Color(0xFF24252B), fillColor: Color(0xFF24252B),
filled: true, filled: true,
@@ -463,10 +481,10 @@ class MyTheme {
labelColor: Colors.white70, labelColor: Colors.white70,
), ),
tooltipTheme: tooltipTheme(), tooltipTheme: tooltipTheme(),
splashColor: isDesktop ? Colors.transparent : null, splashColor: (isDesktop || isWebDesktop) ? Colors.transparent : null,
highlightColor: isDesktop ? Colors.transparent : null, highlightColor: (isDesktop || isWebDesktop) ? Colors.transparent : null,
splashFactory: isDesktop ? NoSplash.splashFactory : null, splashFactory: (isDesktop || isWebDesktop) ? NoSplash.splashFactory : null,
textButtonTheme: isDesktop textButtonTheme: (isDesktop || isWebDesktop)
? TextButtonThemeData( ? TextButtonThemeData(
style: TextButton.styleFrom( style: TextButton.styleFrom(
splashFactory: NoSplash.splashFactory, splashFactory: NoSplash.splashFactory,
@@ -631,8 +649,12 @@ closeConnection({String? id}) {
gFFI.chatModel.hideChatOverlay(); gFFI.chatModel.hideChatOverlay();
Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/")); Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
} else { } else {
final controller = Get.find<DesktopTabController>(); if (isWeb) {
controller.closeBy(id); Navigator.popUntil(globalKey.currentContext!, ModalRoute.withName("/"));
} else {
final controller = Get.find<DesktopTabController>();
controller.closeBy(id);
}
} }
} }
@@ -810,7 +832,7 @@ class OverlayDialogManager {
Offstage( Offstage(
offstage: !showCancel, offstage: !showCancel,
child: Center( child: Center(
child: isDesktop child: (isDesktop || isWebDesktop)
? dialogButton('Cancel', onPressed: cancel) ? dialogButton('Cancel', onPressed: cancel)
: TextButton( : TextButton(
style: flatButtonStyle, style: flatButtonStyle,
@@ -1285,7 +1307,7 @@ class AndroidPermissionManager {
} }
static Future<bool> check(String type) { static Future<bool> check(String type) {
if (isDesktop) { if (isDesktop || isWeb) {
return Future.value(true); return Future.value(true);
} }
return gFFI.invokeMethod("check_permission", type); return gFFI.invokeMethod("check_permission", type);
@@ -1299,7 +1321,7 @@ class AndroidPermissionManager {
/// We use XXPermissions to request permissions, /// We use XXPermissions to request permissions,
/// for supported types, see https://github.com/getActivity/XXPermissions/blob/e46caea32a64ad7819df62d448fb1c825481cd28/library/src/main/java/com/hjq/permissions/Permission.java /// for supported types, see https://github.com/getActivity/XXPermissions/blob/e46caea32a64ad7819df62d448fb1c825481cd28/library/src/main/java/com/hjq/permissions/Permission.java
static Future<bool> request(String type) { static Future<bool> request(String type) {
if (isDesktop) { if (isDesktop || isWeb) {
return Future.value(true); return Future.value(true);
} }
@@ -1521,6 +1543,12 @@ class LastWindowPosition {
} }
} }
String get windowFramePrefix =>
kWindowPrefix +
(bind.isIncomingOnly()
? "incoming_"
: (bind.isOutgoingOnly() ? "outgoing_" : ""));
/// Save window position and size on exit /// Save window position and size on exit
/// Note that windowId must be provided if it's subwindow /// Note that windowId must be provided if it's subwindow
Future<void> saveWindowPosition(WindowType type, {int? windowId}) async { Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
@@ -1533,10 +1561,10 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
late Size sz; late Size sz;
late bool isMaximized; late bool isMaximized;
bool isFullscreen = stateGlobal.fullscreen.isTrue || bool isFullscreen = stateGlobal.fullscreen.isTrue ||
(Platform.isMacOS && stateGlobal.closeOnFullscreen == true); (isMacOS && stateGlobal.closeOnFullscreen == true);
setFrameIfMaximized() { setFrameIfMaximized() {
if (isMaximized) { if (isMaximized) {
final pos = bind.getLocalFlutterOption(k: kWindowPrefix + type.name); final pos = bind.getLocalFlutterOption(k: windowFramePrefix + type.name);
var lpos = LastWindowPosition.loadFromString(pos); var lpos = LastWindowPosition.loadFromString(pos);
position = Offset( position = Offset(
lpos?.offsetWidth ?? position.dx, lpos?.offsetHeight ?? position.dy); lpos?.offsetWidth ?? position.dx, lpos?.offsetHeight ?? position.dy);
@@ -1546,7 +1574,13 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
switch (type) { switch (type) {
case WindowType.Main: case WindowType.Main:
isMaximized = await windowManager.isMaximized(); // Checking `bind.isIncomingOnly()` is a simple workaround for MacOS.
// `await windowManager.isMaximized()` will always return true
// if is not resizable. The reason is unknown.
//
// `setResizable(!bind.isIncomingOnly());` in main.dart
isMaximized =
bind.isIncomingOnly() ? false : await windowManager.isMaximized();
position = await windowManager.getPosition(); position = await windowManager.getPosition();
sz = await windowManager.getSize(); sz = await windowManager.getSize();
setFrameIfMaximized(); setFrameIfMaximized();
@@ -1566,7 +1600,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
setFrameIfMaximized(); setFrameIfMaximized();
break; break;
} }
if (Platform.isWindows) { if (isWindows) {
const kMinOffset = -10000; const kMinOffset = -10000;
const kMaxOffset = 10000; const kMaxOffset = 10000;
if (position.dx < kMinOffset || if (position.dx < kMinOffset ||
@@ -1584,7 +1618,7 @@ Future<void> saveWindowPosition(WindowType type, {int? windowId}) async {
"Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}, isMaximized:${pos.isMaximized}, isFullscreen:${pos.isFullscreen}"); "Saving frame: $windowId: ${pos.width}/${pos.height}, offset:${pos.offsetWidth}/${pos.offsetHeight}, isMaximized:${pos.isMaximized}, isFullscreen:${pos.isFullscreen}");
await bind.setLocalFlutterOption( await bind.setLocalFlutterOption(
k: kWindowPrefix + type.name, v: pos.toString()); k: windowFramePrefix + type.name, v: pos.toString());
if (type == WindowType.RemoteDesktop && windowId != null) { if (type == WindowType.RemoteDesktop && windowId != null) {
await _saveSessionWindowPosition( await _saveSessionWindowPosition(
@@ -1599,7 +1633,7 @@ Future _saveSessionWindowPosition(WindowType windowType, int windowId,
getPeerPos(String peerId) { getPeerPos(String peerId) {
if (isMaximized) { if (isMaximized) {
final peerPos = bind.mainGetPeerFlutterOptionSync( final peerPos = bind.mainGetPeerFlutterOptionSync(
id: peerId, k: kWindowPrefix + windowType.name); id: peerId, k: windowFramePrefix + windowType.name);
var lpos = LastWindowPosition.loadFromString(peerPos); var lpos = LastWindowPosition.loadFromString(peerPos);
return LastWindowPosition( return LastWindowPosition(
lpos?.width ?? pos.offsetWidth, lpos?.width ?? pos.offsetWidth,
@@ -1618,7 +1652,7 @@ Future _saveSessionWindowPosition(WindowType windowType, int windowId,
for (final peerId in remoteList.split(',')) { for (final peerId in remoteList.split(',')) {
bind.mainSetPeerFlutterOptionSync( bind.mainSetPeerFlutterOptionSync(
id: peerId, id: peerId,
k: kWindowPrefix + windowType.name, k: windowFramePrefix + windowType.name,
v: getPeerPos(peerId)); v: getPeerPos(peerId));
} }
} }
@@ -1736,14 +1770,14 @@ Future<bool> restoreWindowPosition(WindowType type,
// Because the session may not be read at this time. // Because the session may not be read at this time.
if (desktopType == DesktopType.main) { if (desktopType == DesktopType.main) {
pos = bind.mainGetPeerFlutterOptionSync( pos = bind.mainGetPeerFlutterOptionSync(
id: peerId, k: kWindowPrefix + type.name); id: peerId, k: windowFramePrefix + type.name);
} else { } else {
pos = await bind.sessionGetFlutterOptionByPeerId( pos = await bind.sessionGetFlutterOptionByPeerId(
id: peerId, k: kWindowPrefix + type.name); id: peerId, k: windowFramePrefix + type.name);
} }
isRemotePeerPos = pos != null; isRemotePeerPos = pos != null;
} }
pos ??= bind.getLocalFlutterOption(k: kWindowPrefix + type.name); pos ??= bind.getLocalFlutterOption(k: windowFramePrefix + type.name);
var lpos = LastWindowPosition.loadFromString(pos); var lpos = LastWindowPosition.loadFromString(pos);
if (lpos == null) { if (lpos == null) {
@@ -1790,9 +1824,13 @@ Future<bool> restoreWindowPosition(WindowType type,
} }
if (lpos.isMaximized == true) { if (lpos.isMaximized == true) {
await restorePos(); await restorePos();
await windowManager.maximize(); if (!(bind.isIncomingOnly() || bind.isOutgoingOnly())) {
await windowManager.maximize();
}
} else { } else {
await windowManager.setSize(size); if (!bind.isIncomingOnly() || bind.isOutgoingOnly()) {
await windowManager.setSize(size);
}
await restorePos(); await restorePos();
} }
return true; return true;
@@ -1833,13 +1871,14 @@ Future<bool> restoreWindowPosition(WindowType type,
/// initUniLinks should only be used on macos/windows. /// initUniLinks should only be used on macos/windows.
/// we use dbus for linux currently. /// we use dbus for linux currently.
Future<bool> initUniLinks() async { Future<bool> initUniLinks() async {
if (Platform.isLinux) { if (isLinux) {
return false; return false;
} }
// check cold boot // check cold boot
try { try {
final initialLink = await getInitialLink(); final initialLink = await getInitialLink();
if (initialLink == null) { print("initialLink: $initialLink");
if (initialLink == null || initialLink.isEmpty) {
return false; return false;
} }
return handleUriLink(uriString: initialLink); return handleUriLink(uriString: initialLink);
@@ -1855,7 +1894,7 @@ Future<bool> initUniLinks() async {
/// ///
/// Returns a [StreamSubscription] which can listen the uni links. /// Returns a [StreamSubscription] which can listen the uni links.
StreamSubscription? listenUniLinks({handleByFlutter = true}) { StreamSubscription? listenUniLinks({handleByFlutter = true}) {
if (Platform.isLinux) { if (isLinux) {
return null; return null;
} }
@@ -1889,7 +1928,7 @@ bool handleUriLink({List<String>? cmdArgs, Uri? uri, String? uriString}) {
if (cmdArgs != null && cmdArgs.isNotEmpty) { if (cmdArgs != null && cmdArgs.isNotEmpty) {
args = cmdArgs; args = cmdArgs;
// rustdesk <uri link> // rustdesk <uri link>
if (args[0].startsWith(kUniLinksPrefix)) { if (args[0].startsWith(bind.mainUriPrefixSync())) {
final uri = Uri.tryParse(args[0]); final uri = Uri.tryParse(args[0]);
if (uri != null) { if (uri != null) {
args = urlLinkToCmdArgs(uri); args = urlLinkToCmdArgs(uri);
@@ -2003,7 +2042,7 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
command = '--connect'; command = '--connect';
id = uri.path.substring("/new/".length); id = uri.path.substring("/new/".length);
} else if (uri.authority == "config") { } else if (uri.authority == "config") {
if (Platform.isAndroid || Platform.isIOS) { if (isAndroid || isIOS) {
final config = uri.path.substring("/".length); final config = uri.path.substring("/".length);
// add a timer to make showToast work // add a timer to make showToast work
Timer(Duration(seconds: 1), () { Timer(Duration(seconds: 1), () {
@@ -2012,7 +2051,7 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
} }
return null; return null;
} else if (uri.authority == "password") { } else if (uri.authority == "password") {
if (Platform.isAndroid || Platform.isIOS) { if (isAndroid || isIOS) {
final password = uri.path.substring("/".length); final password = uri.path.substring("/".length);
if (password.isNotEmpty) { if (password.isNotEmpty) {
Timer(Duration(seconds: 1), () async { Timer(Duration(seconds: 1), () async {
@@ -2079,19 +2118,28 @@ List<String>? urlLinkToCmdArgs(Uri uri) {
return null; return null;
} }
connectMainDesktop( connectMainDesktop(String id,
String id, { {required bool isFileTransfer,
required bool isFileTransfer, required bool isTcpTunneling,
required bool isTcpTunneling, required bool isRDP,
required bool isRDP, bool? forceRelay,
bool? forceRelay, String? password,
}) async { bool? isSharedPassword}) async {
if (isFileTransfer) { if (isFileTransfer) {
await rustDeskWinManager.newFileTransfer(id, forceRelay: forceRelay); await rustDeskWinManager.newFileTransfer(id,
password: password,
isSharedPassword: isSharedPassword,
forceRelay: forceRelay);
} else if (isTcpTunneling || isRDP) { } else if (isTcpTunneling || isRDP) {
await rustDeskWinManager.newPortForward(id, isRDP, forceRelay: forceRelay); await rustDeskWinManager.newPortForward(id, isRDP,
password: password,
isSharedPassword: isSharedPassword,
forceRelay: forceRelay);
} else { } else {
await rustDeskWinManager.newRemoteDesktop(id, forceRelay: forceRelay); await rustDeskWinManager.newRemoteDesktop(id,
password: password,
isSharedPassword: isSharedPassword,
forceRelay: forceRelay);
} }
} }
@@ -2099,14 +2147,13 @@ connectMainDesktop(
/// If [isFileTransfer], starts a session only for file transfer. /// If [isFileTransfer], starts a session only for file transfer.
/// If [isTcpTunneling], starts a session only for tcp tunneling. /// If [isTcpTunneling], starts a session only for tcp tunneling.
/// If [isRDP], starts a session only for rdp. /// If [isRDP], starts a session only for rdp.
connect( connect(BuildContext context, String id,
BuildContext context, {bool isFileTransfer = false,
String id, { bool isTcpTunneling = false,
bool isFileTransfer = false, bool isRDP = false,
bool isTcpTunneling = false, bool forceRelay = false,
bool isRDP = false, String? password,
bool forceRelay = false, bool? isSharedPassword}) async {
}) async {
if (id == '') return; if (id == '') return;
if (!isDesktop || desktopType == DesktopType.main) { if (!isDesktop || desktopType == DesktopType.main) {
try { try {
@@ -2134,6 +2181,8 @@ connect(
isFileTransfer: isFileTransfer, isFileTransfer: isFileTransfer,
isTcpTunneling: isTcpTunneling, isTcpTunneling: isTcpTunneling,
isRDP: isRDP, isRDP: isRDP,
password: password,
isSharedPassword: isSharedPassword,
forceRelay: forceRelay2, forceRelay: forceRelay2,
); );
} else { } else {
@@ -2142,6 +2191,8 @@ connect(
'isFileTransfer': isFileTransfer, 'isFileTransfer': isFileTransfer,
'isTcpTunneling': isTcpTunneling, 'isTcpTunneling': isTcpTunneling,
'isRDP': isRDP, 'isRDP': isRDP,
'password': password,
'isSharedPassword': isSharedPassword,
'forceRelay': forceRelay, 'forceRelay': forceRelay,
}); });
} }
@@ -2155,16 +2206,34 @@ connect(
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (BuildContext context) => FileManagerPage(id: id), builder: (BuildContext context) => FileManagerPage(
id: id, password: password, isSharedPassword: isSharedPassword),
), ),
); );
} else { } else {
Navigator.push( if (isWebDesktop) {
context, Navigator.push(
MaterialPageRoute( context,
builder: (BuildContext context) => RemotePage(id: id), MaterialPageRoute(
), builder: (BuildContext context) => desktop_remote.RemotePage(
); key: ValueKey(id),
id: id,
toolbarState: ToolbarState(),
password: password,
forceRelay: forceRelay,
isSharedPassword: isSharedPassword,
),
),
);
} else {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => RemotePage(
id: id, password: password, isSharedPassword: isSharedPassword),
),
);
}
} }
} }
@@ -2218,7 +2287,7 @@ Future<void> reloadAllWindows() async {
/// [Note] /// [Note]
/// Portable build is only available on Windows. /// Portable build is only available on Windows.
bool isRunningInPortableMode() { bool isRunningInPortableMode() {
if (!Platform.isWindows) { if (!isWindows) {
return false; return false;
} }
return bool.hasEnvironment(kEnvPortableExecutable); return bool.hasEnvironment(kEnvPortableExecutable);
@@ -2231,7 +2300,7 @@ Future<void> onActiveWindowChanged() async {
if (rustDeskWinManager.getActiveWindows().isEmpty) { if (rustDeskWinManager.getActiveWindows().isEmpty) {
// close all sub windows // close all sub windows
try { try {
if (Platform.isLinux) { if (isLinux) {
await Future.wait([ await Future.wait([
saveWindowPosition(WindowType.Main), saveWindowPosition(WindowType.Main),
rustDeskWinManager.closeAllSubWindows() rustDeskWinManager.closeAllSubWindows()
@@ -2245,7 +2314,7 @@ Future<void> onActiveWindowChanged() async {
debugPrint("Start closing RustDesk..."); debugPrint("Start closing RustDesk...");
await windowManager.setPreventClose(false); await windowManager.setPreventClose(false);
await windowManager.close(); await windowManager.close();
if (Platform.isMacOS) { if (isMacOS) {
RdPlatformChannel.instance.terminate(); RdPlatformChannel.instance.terminate();
} }
} }
@@ -2261,7 +2330,7 @@ Timer periodic_immediate(Duration duration, Future<void> Function() callback) {
/// return a human readable windows version /// return a human readable windows version
WindowsTarget getWindowsTarget(int buildNumber) { WindowsTarget getWindowsTarget(int buildNumber) {
if (!Platform.isWindows) { if (!isWindows) {
return WindowsTarget.naw; return WindowsTarget.naw;
} }
if (buildNumber >= 22000) { if (buildNumber >= 22000) {
@@ -2287,35 +2356,7 @@ WindowsTarget getWindowsTarget(int buildNumber) {
/// [Note] /// [Note]
/// Please use this function wrapped with `Platform.isWindows`. /// Please use this function wrapped with `Platform.isWindows`.
int getWindowsTargetBuildNumber() { int getWindowsTargetBuildNumber() {
final rtlGetVersion = DynamicLibrary.open('ntdll.dll').lookupFunction< return getWindowsTargetBuildNumber_();
Void Function(Pointer<win32.OSVERSIONINFOEX>),
void Function(Pointer<win32.OSVERSIONINFOEX>)>('RtlGetVersion');
final osVersionInfo = getOSVERSIONINFOEXPointer();
rtlGetVersion(osVersionInfo);
int buildNumber = osVersionInfo.ref.dwBuildNumber;
calloc.free(osVersionInfo);
return buildNumber;
}
/// Get Windows OS version pointer
///
/// [Note]
/// Please use this function wrapped with `Platform.isWindows`.
Pointer<win32.OSVERSIONINFOEX> getOSVERSIONINFOEXPointer() {
final pointer = calloc<win32.OSVERSIONINFOEX>();
pointer.ref
..dwOSVersionInfoSize = sizeOf<win32.OSVERSIONINFOEX>()
..dwBuildNumber = 0
..dwMajorVersion = 0
..dwMinorVersion = 0
..dwPlatformId = 0
..szCSDVersion = ''
..wServicePackMajor = 0
..wServicePackMinor = 0
..wSuiteMask = 0
..wProductType = 0
..wReserved = 0;
return pointer;
} }
/// Indicating we need to use compatible ui mode. /// Indicating we need to use compatible ui mode.
@@ -2323,7 +2364,7 @@ Pointer<win32.OSVERSIONINFOEX> getOSVERSIONINFOEXPointer() {
/// [Conditions] /// [Conditions]
/// - Windows 7, window will overflow when we use frameless ui. /// - Windows 7, window will overflow when we use frameless ui.
bool get kUseCompatibleUiMode => bool get kUseCompatibleUiMode =>
Platform.isWindows && isWindows &&
const [WindowsTarget.w7].contains(windowsBuildNumber.windowsVersion); const [WindowsTarget.w7].contains(windowsBuildNumber.windowsVersion);
class ServerConfig { class ServerConfig {
@@ -2387,7 +2428,7 @@ Widget dialogButton(String text,
Widget? icon, Widget? icon,
TextStyle? style, TextStyle? style,
ButtonStyle? buttonStyle}) { ButtonStyle? buttonStyle}) {
if (isDesktop) { if (isDesktop || isWebDesktop) {
if (isOutline) { if (isOutline) {
return icon == null return icon == null
? OutlinedButton( ? OutlinedButton(
@@ -2429,19 +2470,20 @@ int versionCmp(String v1, String v2) {
} }
String getWindowName({WindowType? overrideType}) { String getWindowName({WindowType? overrideType}) {
final name = bind.mainGetAppNameSync();
switch (overrideType ?? kWindowType) { switch (overrideType ?? kWindowType) {
case WindowType.Main: case WindowType.Main:
return "RustDesk"; return name;
case WindowType.FileTransfer: case WindowType.FileTransfer:
return "File Transfer - RustDesk"; return "File Transfer - $name";
case WindowType.PortForward: case WindowType.PortForward:
return "Port Forward - RustDesk"; return "Port Forward - $name";
case WindowType.RemoteDesktop: case WindowType.RemoteDesktop:
return "Remote Desktop - RustDesk"; return "Remote Desktop - $name";
default: default:
break; break;
} }
return "RustDesk"; return name;
} }
String getWindowNameWithId(String id, {WindowType? overrideType}) { String getWindowNameWithId(String id, {WindowType? overrideType}) {
@@ -2452,7 +2494,7 @@ Future<void> updateSystemWindowTheme() async {
// Set system window theme for macOS. // Set system window theme for macOS.
final userPreference = MyTheme.getThemeModePreference(); final userPreference = MyTheme.getThemeModePreference();
if (userPreference != ThemeMode.system) { if (userPreference != ThemeMode.system) {
if (Platform.isMacOS) { if (isMacOS) {
await RdPlatformChannel.instance.changeSystemWindowTheme( await RdPlatformChannel.instance.changeSystemWindowTheme(
userPreference == ThemeMode.light userPreference == ThemeMode.light
? SystemWindowTheme.light ? SystemWindowTheme.light
@@ -2540,7 +2582,7 @@ void onCopyFingerprint(String value) {
Future<bool> callMainCheckSuperUserPermission() async { Future<bool> callMainCheckSuperUserPermission() async {
bool checked = await bind.mainCheckSuperUserPermission(); bool checked = await bind.mainCheckSuperUserPermission();
if (Platform.isMacOS) { if (isMacOS) {
await windowManager.show(); await windowManager.show();
} }
return checked; return checked;
@@ -2548,7 +2590,7 @@ Future<bool> callMainCheckSuperUserPermission() async {
Future<void> start_service(bool is_start) async { Future<void> start_service(bool is_start) async {
bool checked = !bind.mainIsInstalled() || bool checked = !bind.mainIsInstalled() ||
!Platform.isMacOS || !isMacOS ||
await callMainCheckSuperUserPermission(); await callMainCheckSuperUserPermission();
if (checked) { if (checked) {
bind.mainSetOption(key: "stop-service", value: is_start ? "" : "Y"); bind.mainSetOption(key: "stop-service", value: is_start ? "" : "Y");
@@ -2942,16 +2984,16 @@ Future<bool> setServerConfig(
} }
// id // id
if (config.idServer.isNotEmpty && errMsgs != null) { if (config.idServer.isNotEmpty && errMsgs != null) {
errMsgs[0].value = errMsgs[0].value = translate(await bind.mainTestIfValidServer(
translate(await bind.mainTestIfValidServer(server: config.idServer)); server: config.idServer, testWithProxy: true));
if (errMsgs[0].isNotEmpty) { if (errMsgs[0].isNotEmpty) {
return false; return false;
} }
} }
// relay // relay
if (config.relayServer.isNotEmpty && errMsgs != null) { if (config.relayServer.isNotEmpty && errMsgs != null) {
errMsgs[1].value = errMsgs[1].value = translate(await bind.mainTestIfValidServer(
translate(await bind.mainTestIfValidServer(server: config.relayServer)); server: config.relayServer, testWithProxy: true));
if (errMsgs[1].isNotEmpty) { if (errMsgs[1].isNotEmpty) {
return false; return false;
} }
@@ -2973,7 +3015,6 @@ Future<bool> setServerConfig(
await bind.mainSetOption(key: 'relay-server', value: config.relayServer); await bind.mainSetOption(key: 'relay-server', value: config.relayServer);
await bind.mainSetOption(key: 'api-server', value: config.apiServer); await bind.mainSetOption(key: 'api-server', value: config.apiServer);
await bind.mainSetOption(key: 'key', value: config.key); await bind.mainSetOption(key: 'key', value: config.key);
final newApiServer = await bind.mainGetApiServer(); final newApiServer = await bind.mainGetApiServer();
if (oldApiServer.isNotEmpty && if (oldApiServer.isNotEmpty &&
oldApiServer != newApiServer && oldApiServer != newApiServer &&
@@ -3070,3 +3111,173 @@ Color? disabledTextColor(BuildContext context, bool enabled) {
? null ? null
: Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6); : Theme.of(context).textTheme.titleLarge?.color?.withOpacity(0.6);
} }
Widget loadPowered(BuildContext context) {
return MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(
onTap: () {
launchUrl(Uri.parse('https://rustdesk.com'));
},
child: Opacity(
opacity: 0.5,
child: Text(
translate("powered_by_me"),
overflow: TextOverflow.clip,
style: Theme.of(context)
.textTheme
.bodySmall
?.copyWith(fontSize: 9, decoration: TextDecoration.underline),
)),
),
).marginOnly(top: 6);
}
// max 300 x 60
Widget loadLogo() {
return FutureBuilder<ByteData>(
future: rootBundle.load('assets/logo.png'),
builder: (BuildContext context, AsyncSnapshot<ByteData> snapshot) {
if (snapshot.hasData) {
final image = Image.asset(
'assets/logo.png',
fit: BoxFit.contain,
errorBuilder: (ctx, error, stackTrace) {
return Container();
},
);
return Container(
constraints: BoxConstraints(maxWidth: 300, maxHeight: 60),
child: image,
).marginOnly(left: 12, right: 12, top: 12);
}
return const Offstage();
});
}
Widget loadIcon(double size) {
return Image.asset('assets/icon.png',
width: size,
height: size,
errorBuilder: (ctx, error, stackTrace) => SvgPicture.asset(
'assets/icon.svg',
width: size,
height: size,
));
}
var imcomingOnlyHomeSize = Size(280, 300);
Size getIncomingOnlyHomeSize() {
final magicWidth = isWindows ? 11.0 : 2.0;
final magicHeight = 10.0;
return imcomingOnlyHomeSize +
Offset(magicWidth, kDesktopRemoteTabBarHeight + magicHeight);
}
Size getIncomingOnlySettingsSize() {
return Size(768, 600);
}
bool isInHomePage() {
final controller = Get.find<DesktopTabController>();
return controller.state.value.selected == 0;
}
Widget buildPresetPasswordWarning() {
return FutureBuilder<bool>(
future: bind.isPresetPassword(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return CircularProgressIndicator(); // Show a loading spinner while waiting for the Future to complete
} else if (snapshot.hasError) {
return Text(
'Error: ${snapshot.error}'); // Show an error message if the Future completed with an error
} else if (snapshot.hasData && snapshot.data == true) {
return Container(
color: Colors.yellow,
child: Column(
children: [
Align(
child: Text(
translate("Security Alert"),
style: TextStyle(
color: Colors.red,
fontSize: 20,
fontWeight: FontWeight.bold,
),
)).paddingOnly(bottom: 8),
Text(
translate("preset_password_warning"),
style: TextStyle(color: Colors.red),
)
],
).paddingAll(8),
); // Show a warning message if the Future completed with true
} else {
return SizedBox
.shrink(); // Show nothing if the Future completed with false or null
}
},
);
}
// https://github.com/leanflutter/window_manager/blob/87dd7a50b4cb47a375b9fc697f05e56eea0a2ab3/lib/src/widgets/virtual_window_frame.dart#L44
Widget buildVirtualWindowFrame(BuildContext context, Widget child) {
boxShadow() => isMainDesktopWindow
? <BoxShadow>[
if (stateGlobal.fullscreen.isFalse || stateGlobal.isMaximized.isFalse)
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: Offset(
0.0,
stateGlobal.isFocused.isTrue
? kFrameBoxShadowOffsetFocused
: kFrameBoxShadowOffsetUnfocused),
blurRadius: kFrameBoxShadowBlurRadius,
),
]
: null;
return Obx(
() => Container(
decoration: BoxDecoration(
color: isMainDesktopWindow
? Colors.transparent
: Theme.of(context).colorScheme.background,
border: Border.all(
color: Theme.of(context).dividerColor,
width: stateGlobal.windowBorderWidth.value,
),
borderRadius: BorderRadius.circular(
(stateGlobal.fullscreen.isTrue || stateGlobal.isMaximized.isTrue)
? 0
: kFrameBorderRadius,
),
boxShadow: boxShadow(),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(
(stateGlobal.fullscreen.isTrue || stateGlobal.isMaximized.isTrue)
? 0
: kFrameClipRRectBorderRadius,
),
child: child,
),
),
);
}
get windowEdgeSize => isLinux && !_linuxWindowResizable ? 0.0 : kWindowEdgeSize;
// `windowManager.setResizable(false)` will reset the window size to the default size on Linux and then set unresizable.
// See _linuxWindowResizable for more details.
// So we use `setResizable()` instead of `windowManager.setResizable()`.
//
// We can only call `windowManager.setResizable(false)` if we need the default size on Linux.
setResizable(bool resizable) {
if (isLinux) {
_linuxWindowResizable = resizable;
stateGlobal.refreshResizeEdgeSize();
} else {
windowManager.setResizable(resizable);
}
}

View File

@@ -1,5 +1,6 @@
import 'dart:convert'; import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/peer_model.dart'; import 'package:flutter_hbb/models/peer_model.dart';
@@ -188,3 +189,79 @@ class RequestException implements Exception {
return "RequestException, statusCode: $statusCode, error: $cause"; return "RequestException, statusCode: $statusCode, error: $cause";
} }
} }
enum ShareRule {
read(1),
readWrite(2),
fullControl(3);
const ShareRule(this.value);
final int value;
static String desc(int v) {
if (v == ShareRule.read.value) {
return translate('Read-only');
}
if (v == ShareRule.readWrite.value) {
return translate('Read/Write');
}
if (v == ShareRule.fullControl.value) {
return translate('Full Control');
}
return v.toString();
}
static String shortDesc(int v) {
if (v == ShareRule.read.value) {
return 'R';
}
if (v == ShareRule.readWrite.value) {
return 'RW';
}
if (v == ShareRule.fullControl.value) {
return 'F';
}
return v.toString();
}
static ShareRule? fromValue(int v) {
if (v == ShareRule.read.value) {
return ShareRule.read;
}
if (v == ShareRule.readWrite.value) {
return ShareRule.readWrite;
}
if (v == ShareRule.fullControl.value) {
return ShareRule.fullControl;
}
return null;
}
}
class AbProfile {
String guid;
String name;
String owner;
String? note;
int rule;
AbProfile(this.guid, this.name, this.owner, this.note, this.rule);
AbProfile.fromJson(Map<String, dynamic> json)
: guid = json['guid'] ?? '',
name = json['name'] ?? '',
owner = json['owner'] ?? '',
note = json['note'] ?? '',
rule = json['rule'] ?? 0;
}
class AbTag {
String name;
int color;
AbTag(this.name, this.color);
AbTag.fromJson(Map<String, dynamic> json)
: name = json['name'] ?? '',
color = json['color'] ?? '';
}

View File

@@ -168,6 +168,29 @@ class ShowRemoteCursorState {
static RxBool find(String id) => Get.find<RxBool>(tag: tag(id)); static RxBool find(String id) => Get.find<RxBool>(tag: tag(id));
} }
class ShowRemoteCursorLockState {
static String tag(String id) => 'show_remote_cursor_lock_$id';
static void init(String id) {
final key = tag(id);
if (!Get.isRegistered(tag: key)) {
final RxBool state = false.obs;
Get.put(state, tag: key);
} else {
Get.find<RxBool>(tag: key).value = false;
}
}
static void delete(String id) {
final key = tag(id);
if (Get.isRegistered(tag: key)) {
Get.delete(tag: key);
}
}
static RxBool find(String id) => Get.find<RxBool>(tag: tag(id));
}
class KeyboardEnabledState { class KeyboardEnabledState {
static String tag(String id) => 'keyboard_enabled_$id'; static String tag(String id) => 'keyboard_enabled_$id';
@@ -315,6 +338,7 @@ initSharedStates(String id) {
CurrentDisplayState.init(id); CurrentDisplayState.init(id);
KeyboardEnabledState.init(id); KeyboardEnabledState.init(id);
ShowRemoteCursorState.init(id); ShowRemoteCursorState.init(id);
ShowRemoteCursorLockState.init(id);
RemoteCursorMovedState.init(id); RemoteCursorMovedState.init(id);
FingerprintState.init(id); FingerprintState.init(id);
PeerBoolOption.init(id, 'zoom-cursor', () => false); PeerBoolOption.init(id, 'zoom-cursor', () => false);
@@ -327,6 +351,7 @@ removeSharedStates(String id) {
BlockInputState.delete(id); BlockInputState.delete(id);
CurrentDisplayState.delete(id); CurrentDisplayState.delete(id);
ShowRemoteCursorState.delete(id); ShowRemoteCursorState.delete(id);
ShowRemoteCursorLockState.delete(id);
KeyboardEnabledState.delete(id); KeyboardEnabledState.delete(id);
RemoteCursorMovedState.delete(id); RemoteCursorMovedState.delete(id);
FingerprintState.delete(id); FingerprintState.delete(id);

View File

@@ -1,13 +1,16 @@
import 'dart:math'; import 'dart:math';
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:dynamic_layouts/dynamic_layouts.dart'; import 'package:dynamic_layouts/dynamic_layouts.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common/formatter/id_formatter.dart'; import 'package:flutter_hbb/common/formatter/id_formatter.dart';
import 'package:flutter_hbb/common/hbbs/hbbs.dart';
import 'package:flutter_hbb/common/widgets/peer_card.dart'; import 'package:flutter_hbb/common/widgets/peer_card.dart';
import 'package:flutter_hbb/common/widgets/peers_view.dart'; import 'package:flutter_hbb/common/widgets/peers_view.dart';
import 'package:flutter_hbb/desktop/widgets/popup_menu.dart'; import 'package:flutter_hbb/desktop/widgets/popup_menu.dart';
import 'package:flutter_hbb/models/ab_model.dart'; import 'package:flutter_hbb/models/ab_model.dart';
import 'package:flutter_hbb/models/platform_model.dart'; import 'package:flutter_hbb/models/platform_model.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu; import '../../desktop/widgets/material_mod_popup_menu.dart' as mod_menu;
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flex_color_picker/flex_color_picker.dart'; import 'package:flex_color_picker/flex_color_picker.dart';
@@ -43,27 +46,24 @@ class _AddressBookState extends State<AddressBook> {
child: ElevatedButton( child: ElevatedButton(
onPressed: loginDialog, child: Text(translate("Login")))); onPressed: loginDialog, child: Text(translate("Login"))));
} else { } else {
if (gFFI.abModel.abLoading.value && gFFI.abModel.emtpy) {
return const Center(
child: CircularProgressIndicator(),
);
}
return Column( return Column(
children: [ children: [
// NOT use Offstage to wrap LinearProgressIndicator // NOT use Offstage to wrap LinearProgressIndicator
if (gFFI.abModel.retrying.value) LinearProgressIndicator(), if (gFFI.abModel.currentAbLoading.value &&
gFFI.abModel.currentAbEmpty)
const LinearProgressIndicator(),
buildErrorBanner(context, buildErrorBanner(context,
loading: gFFI.abModel.abLoading, loading: gFFI.abModel.currentAbLoading,
err: gFFI.abModel.pullError, err: gFFI.abModel.currentAbPullError,
retry: null, retry: null,
close: () => gFFI.abModel.pullError.value = ''), close: () => gFFI.abModel.currentAbPullError.value = ''),
buildErrorBanner(context, buildErrorBanner(context,
loading: gFFI.abModel.abLoading, loading: gFFI.abModel.currentAbLoading,
err: gFFI.abModel.pushError, err: gFFI.abModel.currentAbPushError,
retry: () => gFFI.abModel.pushAb(isRetry: true), retry: null, // remove retry
close: () => gFFI.abModel.pushError.value = ''), close: () => gFFI.abModel.currentAbPushError.value = ''),
Expanded( Expanded(
child: isDesktop child: (isDesktop || isWebDesktop)
? _buildAddressBookDesktop() ? _buildAddressBookDesktop()
: _buildAddressBookMobile()) : _buildAddressBookMobile())
], ],
@@ -82,19 +82,23 @@ class _AddressBookState extends State<AddressBook> {
border: Border.all( border: Border.all(
color: Theme.of(context).colorScheme.background)), color: Theme.of(context).colorScheme.background)),
child: Container( child: Container(
width: 150, width: 200,
height: double.infinity, height: double.infinity,
padding: const EdgeInsets.all(8.0),
child: Column( child: Column(
children: [ children: [
_buildTagHeader().marginOnly(left: 8.0, right: 0), _buildAbDropdown(),
_buildTagHeader().marginOnly(
left: 8.0,
right: gFFI.abModel.legacyMode.value ? 8.0 : 0,
top: gFFI.abModel.legacyMode.value ? 8.0 : 0),
Expanded( Expanded(
child: Container( child: Container(
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
child: _buildTags(), child: _buildTags(),
), ),
) ),
_buildAbPermission(),
], ],
), ),
), ),
@@ -119,11 +123,13 @@ class _AddressBookState extends State<AddressBook> {
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
_buildAbDropdown(),
_buildTagHeader().marginOnly(left: 8.0, right: 0), _buildTagHeader().marginOnly(left: 8.0, right: 0),
Container( Container(
width: double.infinity, width: double.infinity,
child: _buildTags(), child: _buildTags(),
), ),
_buildAbPermission(),
], ],
), ),
), ),
@@ -133,6 +139,131 @@ class _AddressBookState extends State<AddressBook> {
); );
} }
Widget _buildAbPermission() {
icon(IconData data, String tooltip) {
return Tooltip(
message: translate(tooltip),
waitDuration: Duration.zero,
child: Icon(data, size: 12.0).marginSymmetric(horizontal: 2.0));
}
return Obx(() {
if (gFFI.abModel.legacyMode.value) return Offstage();
if (gFFI.abModel.current.isPersonal()) {
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
icon(Icons.cloud_off, "Personal"),
],
);
} else {
List<Widget> children = [];
final rule = gFFI.abModel.current.sharedProfile()?.rule;
if (rule == ShareRule.read.value) {
children.add(
icon(Icons.visibility, ShareRule.desc(ShareRule.read.value)));
} else if (rule == ShareRule.readWrite.value) {
children
.add(icon(Icons.edit, ShareRule.desc(ShareRule.readWrite.value)));
} else if (rule == ShareRule.fullControl.value) {
children.add(icon(
Icons.security, ShareRule.desc(ShareRule.fullControl.value)));
}
final owner = gFFI.abModel.current.sharedProfile()?.owner;
if (owner != null) {
children.add(icon(Icons.person, "${translate("Owner")}: $owner"));
}
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: children,
);
}
});
}
Widget _buildAbDropdown() {
if (gFFI.abModel.legacyMode.value) {
return Offstage();
}
final names = gFFI.abModel.addressBookNames();
if (!names.contains(gFFI.abModel.currentName.value)) {
return Offstage();
}
final TextEditingController textEditingController = TextEditingController();
return DropdownButton2<String>(
value: gFFI.abModel.currentName.value,
onChanged: (value) {
if (value != null) {
gFFI.abModel.setCurrentName(value);
bind.setLocalFlutterOption(k: 'current-ab-name', v: value);
}
},
underline: Container(
height: 0.7,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
buttonStyleData: ButtonStyleData(height: 48),
menuItemStyleData: MenuItemStyleData(height: 36),
items: names
.map((e) => DropdownMenuItem(
value: e,
child: Row(
children: [
Expanded(
child: Tooltip(
waitDuration: Duration(milliseconds: 500),
message: gFFI.abModel.translatedName(e),
child: Text(
gFFI.abModel.translatedName(e),
style: TextStyle(fontSize: 14.0),
maxLines: 1,
overflow: TextOverflow.ellipsis,
)),
),
],
)))
.toList(),
isExpanded: true,
dropdownSearchData: DropdownSearchData(
searchController: textEditingController,
searchInnerWidgetHeight: 50,
searchInnerWidget: Container(
height: 50,
padding: const EdgeInsets.only(
top: 8,
bottom: 4,
right: 8,
left: 8,
),
child: TextFormField(
expands: true,
maxLines: null,
controller: textEditingController,
decoration: InputDecoration(
isDense: true,
contentPadding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
hintText: translate('Search'),
hintStyle: const TextStyle(fontSize: 12),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
),
),
),
),
searchMatchFn: (item, searchValue) {
return item.value
.toString()
.toLowerCase()
.contains(searchValue.toLowerCase());
},
),
);
}
Widget _buildTagHeader() { Widget _buildTagHeader() {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -154,11 +285,12 @@ class _AddressBookState extends State<AddressBook> {
return Obx(() { return Obx(() {
final List tags; final List tags;
if (gFFI.abModel.sortTags.value) { if (gFFI.abModel.sortTags.value) {
tags = gFFI.abModel.tags.toList(); tags = gFFI.abModel.currentAbTags.toList();
tags.sort(); tags.sort();
} else { } else {
tags = gFFI.abModel.tags; tags = gFFI.abModel.currentAbTags;
} }
final editPermission = gFFI.abModel.current.canWrite();
tagBuilder(String e) { tagBuilder(String e) {
return AddressBookTag( return AddressBookTag(
name: e, name: e,
@@ -169,7 +301,8 @@ class _AddressBookState extends State<AddressBook> {
} else { } else {
gFFI.abModel.selectedTags.add(e); gFFI.abModel.selectedTags.add(e);
} }
}); },
showActionMenu: editPermission);
} }
final gridView = DynamicGridView.builder( final gridView = DynamicGridView.builder(
@@ -181,7 +314,7 @@ class _AddressBookState extends State<AddressBook> {
return tagBuilder(e); return tagBuilder(e);
}); });
final maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0); final maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
return isDesktop return (isDesktop || isWebDesktop)
? gridView ? gridView
: LimitedBox(maxHeight: maxHeight, child: gridView); : LimitedBox(maxHeight: maxHeight, child: gridView);
}); });
@@ -193,7 +326,7 @@ class _AddressBookState extends State<AddressBook> {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: AddressBookPeersView( child: AddressBookPeersView(
menuPadding: widget.menuPadding, menuPadding: widget.menuPadding,
initPeers: gFFI.abModel.peers, getInitPeers: () => gFFI.abModel.currentAbPeers,
)), )),
); );
} }
@@ -207,7 +340,7 @@ class _AddressBookState extends State<AddressBook> {
return shouldSyncAb(); return shouldSyncAb();
}, },
setter: (bool v) async { setter: (bool v) async {
bind.mainSetLocalOption(key: syncAbOption, value: v ? 'Y' : ''); gFFI.abModel.setShouldAsync(v);
}, },
dismissOnClicked: true, dismissOnClicked: true,
); );
@@ -246,13 +379,23 @@ class _AddressBookState extends State<AddressBook> {
} }
void _showMenu(RelativeRect pos) { void _showMenu(RelativeRect pos) {
final canWrite = gFFI.abModel.current.canWrite();
final items = [ final items = [
getEntry(translate("Add ID"), abAddId), if (canWrite) getEntry(translate("Add ID"), addIdToCurrentAb),
getEntry(translate("Add Tag"), abAddTag), if (canWrite) getEntry(translate("Add Tag"), abAddTag),
getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags), getEntry(translate("Unselect all tags"), gFFI.abModel.unsetSelectedTags),
sortMenuItem(), sortMenuItem(),
syncMenuItem(), if (canWrite) syncMenuItem(),
filterMenuItem(), filterMenuItem(),
if (!gFFI.abModel.legacyMode.value && canWrite)
MenuEntryDivider<String>(),
if (!gFFI.abModel.legacyMode.value && canWrite)
getEntry(translate("ab_web_console_tip"), () async {
final url = await bind.mainGetApiServer();
if (await canLaunchUrlString(url)) {
launchUrlString(url);
}
}),
]; ];
mod_menu.showMenu( mod_menu.showMenu(
@@ -271,17 +414,20 @@ class _AddressBookState extends State<AddressBook> {
); );
} }
void abAddId() async { void addIdToCurrentAb() async {
if (gFFI.abModel.isFull(true)) { if (gFFI.abModel.isCurrentAbFull(true)) {
return; return;
} }
var isInProgress = false; var isInProgress = false;
var passwordVisible = false;
IDTextEditingController idController = IDTextEditingController(text: ''); IDTextEditingController idController = IDTextEditingController(text: '');
TextEditingController aliasController = TextEditingController(text: ''); TextEditingController aliasController = TextEditingController(text: '');
final tags = List.of(gFFI.abModel.tags); TextEditingController passwordController = TextEditingController(text: '');
final tags = List.of(gFFI.abModel.currentAbTags);
var selectedTag = List<dynamic>.empty(growable: true).obs; var selectedTag = List<dynamic>.empty(growable: true).obs;
final style = TextStyle(fontSize: 14.0); final style = TextStyle(fontSize: 14.0);
String? errorMsg; String? errorMsg;
final isCurrentAbShared = !gFFI.abModel.current.isPersonal();
gFFI.dialogManager.show((setState, close, context) { gFFI.dialogManager.show((setState, close, context) {
submit() async { submit() async {
@@ -293,22 +439,50 @@ class _AddressBookState extends State<AddressBook> {
if (id.isEmpty) { if (id.isEmpty) {
// pass // pass
} else { } else {
if (gFFI.abModel.idContainBy(id)) { if (gFFI.abModel.idContainByCurrent(id)) {
setState(() { setState(() {
isInProgress = false; isInProgress = false;
errorMsg = translate('ID already exists'); errorMsg = translate('ID already exists');
}); });
return; return;
} }
gFFI.abModel.addId(id, aliasController.text.trim(), selectedTag); var password = '';
gFFI.abModel.pushAb(); if (isCurrentAbShared) {
this.setState(() {}); password = passwordController.text;
}
String? errMsg2 = await gFFI.abModel.addIdToCurrent(
id, aliasController.text.trim(), password, selectedTag);
if (errMsg2 != null) {
setState(() {
isInProgress = false;
errorMsg = errMsg2;
});
return;
}
// final currentPeers // final currentPeers
} }
close(); close();
} }
double marginBottom = 4; double marginBottom = 4;
row({required Widget lable, required Widget input}) {
return Row(
children: [
!isMobile
? ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: lable.marginOnly(right: 10))
: SizedBox.shrink(),
Expanded(
child: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 200),
child: input),
),
],
).marginOnly(bottom: !isMobile ? 8 : 0);
}
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate("Add ID")), title: Text(translate("Add ID")),
content: Column( content: Column(
@@ -316,66 +490,103 @@ class _AddressBookState extends State<AddressBook> {
children: [ children: [
Column( Column(
children: [ children: [
Align( row(
alignment: Alignment.centerLeft, lable: Row(
child: Row( children: [
children: [ Text(
Text( '*',
'*', style: TextStyle(color: Colors.red, fontSize: 14),
style: TextStyle(color: Colors.red, fontSize: 14), ),
), Text(
Text( 'ID',
'ID', style: style,
style: style, ),
), ],
], ),
), input: TextField(
).marginOnly(bottom: marginBottom), controller: idController,
TextField( inputFormatters: [IDTextInputFormatter()],
controller: idController, decoration: InputDecoration(
inputFormatters: [IDTextInputFormatter()], labelText: !isMobile ? null : translate('ID'),
decoration: InputDecoration(errorText: errorMsg), errorText: errorMsg,
), errorMaxLines: 5),
Align( )),
alignment: Alignment.centerLeft, row(
child: Text( lable: Text(
translate('Alias'), translate('Alias'),
style: style, style: style,
), ),
).marginOnly(top: 8, bottom: marginBottom), input: TextField(
TextField( controller: aliasController,
controller: aliasController, decoration: InputDecoration(
labelText: !isMobile ? null : translate('Alias'),
)),
), ),
Align( if (isCurrentAbShared)
alignment: Alignment.centerLeft, row(
child: Text( lable: Text(
translate('Tags'), translate('Password'),
style: style, style: style,
), ),
).marginOnly(top: 8, bottom: marginBottom), input: TextField(
Align( controller: passwordController,
alignment: Alignment.centerLeft, obscureText: !passwordVisible,
child: Wrap( decoration: InputDecoration(
children: tags labelText: !isMobile ? null : translate('Password'),
.map((e) => AddressBookTag( suffixIcon: IconButton(
name: e, icon: Icon(
tags: selectedTag, passwordVisible
onTap: () { ? Icons.visibility
if (selectedTag.contains(e)) { : Icons.visibility_off,
selectedTag.remove(e); color: MyTheme.lightTheme.primaryColor),
} else { onPressed: () {
selectedTag.add(e); setState(() {
} passwordVisible = !passwordVisible;
});
}, },
showActionMenu: false)) ),
.toList(growable: false), ),
)),
if (gFFI.abModel.currentAbTags.isNotEmpty)
Align(
alignment: Alignment.centerLeft,
child: Text(
translate('Tags'),
style: style,
),
).marginOnly(top: 8, bottom: marginBottom),
if (gFFI.abModel.currentAbTags.isNotEmpty)
Align(
alignment: Alignment.centerLeft,
child: Wrap(
children: tags
.map((e) => AddressBookTag(
name: e,
tags: selectedTag,
onTap: () {
if (selectedTag.contains(e)) {
selectedTag.remove(e);
} else {
selectedTag.add(e);
}
},
showActionMenu: false))
.toList(growable: false),
),
), ),
),
], ],
), ),
const SizedBox( const SizedBox(
height: 4.0, height: 4.0,
), ),
if (!gFFI.abModel.current.isPersonal())
Row(children: [
Icon(Icons.info, color: Colors.amber).marginOnly(right: 4),
Text(
translate('share_warning_tip'),
style: TextStyle(fontSize: 12),
)
]).marginSymmetric(vertical: 10),
// NOT use Offstage to wrap LinearProgressIndicator // NOT use Offstage to wrap LinearProgressIndicator
if (isInProgress) const LinearProgressIndicator(), if (isInProgress) const LinearProgressIndicator(),
], ],
@@ -407,10 +618,7 @@ class _AddressBookState extends State<AddressBook> {
} else { } else {
final tags = field.trim().split(RegExp(r"[\s,;\n]+")); final tags = field.trim().split(RegExp(r"[\s,;\n]+"));
field = tags.join(','); field = tags.join(',');
for (final tag in tags) { gFFI.abModel.addTags(tags);
gFFI.abModel.addTag(tag);
}
gFFI.abModel.pushAb();
// final currentPeers // final currentPeers
} }
close(); close();
@@ -491,7 +699,7 @@ class AddressBookTag extends StatelessWidget {
child: Obx(() => Container( child: Obx(() => Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: tags.contains(name) color: tags.contains(name)
? gFFI.abModel.getTagColor(name) ? gFFI.abModel.getCurrentAbTagColor(name)
: Theme.of(context).colorScheme.background, : Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(4)), borderRadius: BorderRadius.circular(4)),
margin: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0), margin: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 4.0),
@@ -506,7 +714,7 @@ class AddressBookTag extends StatelessWidget {
shape: BoxShape.circle, shape: BoxShape.circle,
color: tags.contains(name) color: tags.contains(name)
? Colors.white ? Colors.white
: gFFI.abModel.getTagColor(name)), : gFFI.abModel.getCurrentAbTagColor(name)),
).marginOnly(right: radius / 2), ).marginOnly(right: radius / 2),
Expanded( Expanded(
child: Text(name, child: Text(name,
@@ -530,7 +738,8 @@ class AddressBookTag extends StatelessWidget {
if (newName == null || newName.isEmpty) { if (newName == null || newName.isEmpty) {
return translate('Can not be empty'); return translate('Can not be empty');
} }
if (newName != name && gFFI.abModel.tags.contains(newName)) { if (newName != name &&
gFFI.abModel.currentAbTags.contains(newName)) {
return translate('Already exists'); return translate('Already exists');
} }
return null; return null;
@@ -538,7 +747,6 @@ class AddressBookTag extends StatelessWidget {
onSubmit: (String newName) { onSubmit: (String newName) {
if (name != newName) { if (name != newName) {
gFFI.abModel.renameTag(name, newName); gFFI.abModel.renameTag(name, newName);
gFFI.abModel.pushAb();
} }
Future.delayed(Duration.zero, () => Get.back()); Future.delayed(Duration.zero, () => Get.back());
}, },
@@ -548,7 +756,7 @@ class AddressBookTag extends StatelessWidget {
}), }),
getEntry(translate(translate('Change Color')), () async { getEntry(translate(translate('Change Color')), () async {
final model = gFFI.abModel; final model = gFFI.abModel;
Color oldColor = model.getTagColor(name); Color oldColor = model.getCurrentAbTagColor(name);
Color newColor = await showColorPickerDialog( Color newColor = await showColorPickerDialog(
context, context,
oldColor, oldColor,
@@ -567,12 +775,10 @@ class AddressBookTag extends StatelessWidget {
); );
if (oldColor != newColor) { if (oldColor != newColor) {
model.setTagColor(name, newColor); model.setTagColor(name, newColor);
model.pushAb();
} }
}), }),
getEntry(translate("Delete"), () { getEntry(translate("Delete"), () {
gFFI.abModel.deleteTag(name); gFFI.abModel.deleteTag(name);
gFFI.abModel.pushAb();
Future.delayed(Duration.zero, () => Get.back()); Future.delayed(Duration.zero, () => Get.back());
}), }),
]; ];

View File

@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/models/platform_model.dart';
typedef AudioINputSetDevice = void Function(String device);
typedef AudioInputBuilder = Widget Function(
List<String> devices, String currentDevice, AudioINputSetDevice setDevice);
class AudioInput extends StatelessWidget {
final AudioInputBuilder builder;
const AudioInput({Key? key, required this.builder}) : super(key: key);
static String getDefault() {
if (isWindows) return translate('System Sound');
return '';
}
static Future<String> getValue() async {
String device = await bind.mainGetOption(key: 'audio-input');
if (device.isNotEmpty) {
return device;
} else {
return getDefault();
}
}
static Future<void> setDevice(String device) async {
if (device == getDefault()) device = '';
await bind.mainSetOption(key: 'audio-input', value: device);
}
static Future<Map<String, Object>> getDevicesInfo() async {
List<String> devices = (await bind.mainGetSoundInputs()).toList();
if (isWindows) {
devices.insert(0, translate('System Sound'));
}
String current = await getValue();
return {'devices': devices, 'current': current};
}
@override
Widget build(BuildContext context) {
return futureBuilder(
future: getDevicesInfo(),
hasData: (data) {
String currentDevice = data['current'];
List<String> devices = data['devices'] as List<String>;
if (devices.isEmpty) {
return const Offstage();
}
return builder(devices, currentDevice, setDevice);
},
);
}
}

View File

@@ -9,9 +9,6 @@ import 'package:flutter_hbb/common/widgets/peer_card.dart';
Future<List<Peer>> getAllPeers() async { Future<List<Peer>> getAllPeers() async {
Map<String, dynamic> recentPeers = jsonDecode(bind.mainLoadRecentPeersSync()); Map<String, dynamic> recentPeers = jsonDecode(bind.mainLoadRecentPeersSync());
Map<String, dynamic> lanPeers = jsonDecode(bind.mainLoadLanPeersSync()); Map<String, dynamic> lanPeers = jsonDecode(bind.mainLoadLanPeersSync());
Map<String, dynamic> abPeers = jsonDecode(bind.mainLoadAbSync());
Map<String, dynamic> groupPeers = jsonDecode(bind.mainLoadGroupSync());
Map<String, dynamic> combinedPeers = {}; Map<String, dynamic> combinedPeers = {};
void mergePeers(Map<String, dynamic> peers) { void mergePeers(Map<String, dynamic> peers) {
@@ -42,8 +39,16 @@ Future<List<Peer>> getAllPeers() async {
mergePeers(recentPeers); mergePeers(recentPeers);
mergePeers(lanPeers); mergePeers(lanPeers);
mergePeers(abPeers); for (var p in gFFI.abModel.allPeers()) {
mergePeers(groupPeers); if (!combinedPeers.containsKey(p.id)) {
combinedPeers[p.id] = p.toJson();
}
}
for (var p in gFFI.groupModel.peers.map((e) => Peer.copy(e)).toList()) {
if (!combinedPeers.containsKey(p.id)) {
combinedPeers[p.id] = p.toJson();
}
}
List<Peer> parsedPeers = []; List<Peer> parsedPeers = [];
@@ -181,7 +186,7 @@ class AutocompletePeerTileState extends State<AutocompletePeerTile> {
], ],
)))); ))));
final colors = _frontN(widget.peer.tags, 25) final colors = _frontN(widget.peer.tags, 25)
.map((e) => gFFI.abModel.getTagColor(e)) .map((e) => gFFI.abModel.getCurrentAbTagColor(e))
.toList(); .toList();
return Tooltip( return Tooltip(
message: isMobile message: isMobile

View File

@@ -1,12 +1,14 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hbb/common/shared_state.dart'; import 'package:flutter_hbb/common/shared_state.dart';
import 'package:flutter_hbb/common/widgets/setting_widgets.dart'; import 'package:flutter_hbb/common/widgets/setting_widgets.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/peer_model.dart';
import 'package:flutter_hbb/models/peer_tab_model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:qr_flutter/qr_flutter.dart'; import 'package:qr_flutter/qr_flutter.dart';
@@ -78,7 +80,7 @@ void changeIdDialog() {
final Iterable violations = rules.where((r) => !r.validate(newId)); final Iterable violations = rules.where((r) => !r.validate(newId));
if (violations.isNotEmpty) { if (violations.isNotEmpty) {
setState(() { setState(() {
msg = isDesktop msg = (isDesktop || isWebDesktop)
? '${translate('Prompt')}: ${violations.map((r) => r.name).join(', ')}' ? '${translate('Prompt')}: ${violations.map((r) => r.name).join(', ')}'
: violations.map((r) => r.name).join(', '); : violations.map((r) => r.name).join(', ');
}); });
@@ -103,7 +105,7 @@ void changeIdDialog() {
} }
setState(() { setState(() {
isInProgress = false; isInProgress = false;
msg = isDesktop msg = (isDesktop || isWebDesktop)
? '${translate('Prompt')}: ${translate(status)}' ? '${translate('Prompt')}: ${translate(status)}'
: translate(status); : translate(status);
}); });
@@ -140,7 +142,7 @@ void changeIdDialog() {
const SizedBox( const SizedBox(
height: 8.0, height: 8.0,
), ),
isDesktop (isDesktop || isWebDesktop)
? Obx(() => Wrap( ? Obx(() => Wrap(
runSpacing: 8, runSpacing: 8,
spacing: 4, spacing: 4,
@@ -622,7 +624,7 @@ class _DialogVerificationCodeField extends State<DialogVerificationCodeField> {
// software secure keyboard will take the focus since flutter 3.13 // software secure keyboard will take the focus since flutter 3.13
// request focus again when android account password obtain focus // request focus again when android account password obtain focus
if (Platform.isAndroid && widget.reRequestFocus) { if (isAndroid && widget.reRequestFocus) {
_focusNode.addListener(() { _focusNode.addListener(() {
if (_focusNode.hasFocus) { if (_focusNode.hasFocus) {
_timerReRequestFocus?.cancel(); _timerReRequestFocus?.cancel();
@@ -691,7 +693,7 @@ class _PasswordWidgetState extends State<PasswordWidget> {
} }
// software secure keyboard will take the focus since flutter 3.13 // software secure keyboard will take the focus since flutter 3.13
// request focus again when android account password obtain focus // request focus again when android account password obtain focus
if (Platform.isAndroid && widget.reRequestFocus) { if (isAndroid && widget.reRequestFocus) {
_focusNode.addListener(() { _focusNode.addListener(() {
if (_focusNode.hasFocus) { if (_focusNode.hasFocus) {
_timerReRequestFocus?.cancel(); _timerReRequestFocus?.cancel();
@@ -1106,7 +1108,7 @@ void showRequestElevationDialog(
errorText: errPwd.isEmpty ? null : errPwd.value, errorText: errPwd.isEmpty ? null : errPwd.value,
), ),
], ],
).marginOnly(left: isDesktop ? 35 : 0), ).marginOnly(left: (isDesktop || isWebDesktop) ? 35 : 0),
).marginOnly(top: 10), ).marginOnly(top: 10),
], ],
), ),
@@ -1583,7 +1585,7 @@ customImageQualityDialog(SessionID sessionId, String id, FFI ffi) async {
msgBoxCommon(ffi.dialogManager, 'Custom Image Quality', content, [btnClose]); msgBoxCommon(ffi.dialogManager, 'Custom Image Quality', content, [btnClose]);
} }
void deletePeerConfirmDialog(Function onSubmit, String title) async { void deleteConfirmDialog(Function onSubmit, String title) async {
gFFI.dialogManager.show( gFFI.dialogManager.show(
(setState, close, context) { (setState, close, context) {
submit() async { submit() async {
@@ -1631,7 +1633,7 @@ void editAbTagDialog(
List<dynamic> currentTags, Function(List<dynamic>) onSubmit) { List<dynamic> currentTags, Function(List<dynamic>) onSubmit) {
var isInProgress = false; var isInProgress = false;
final tags = List.of(gFFI.abModel.tags); final tags = List.of(gFFI.abModel.currentAbTags);
var selectedTag = currentTags.obs; var selectedTag = currentTags.obs;
gFFI.dialogManager.show((setState, close, context) { gFFI.dialogManager.show((setState, close, context) {
@@ -1909,3 +1911,207 @@ void showWindowsSessionsDialog(
); );
}); });
} }
void addPeersToAbDialog(
List<Peer> peers,
) async {
Future<bool> addTo(String abname) async {
final mapList = peers.map((e) {
var json = e.toJson();
// remove password when add to another address book to avoid re-share
json.remove('password');
json.remove('hash');
return json;
}).toList();
final errMsg = await gFFI.abModel.addPeersTo(mapList, abname);
if (errMsg == null) {
showToast(translate('Successful'));
return true;
} else {
BotToast.showText(text: errMsg, contentColor: Colors.red);
return false;
}
}
// if only one address book and it is personal, add to it directly
if (gFFI.abModel.addressbooks.length == 1 &&
gFFI.abModel.current.isPersonal()) {
await addTo(gFFI.abModel.currentName.value);
return;
}
RxBool isInProgress = false.obs;
final names = gFFI.abModel.addressBooksCanWrite();
RxString currentName = gFFI.abModel.currentName.value.obs;
TextEditingController controller = TextEditingController();
if (gFFI.peerTabModel.currentTab == PeerTabIndex.ab.index) {
names.remove(currentName.value);
}
if (names.isEmpty) {
debugPrint('no address book to add peers to, should not happen');
return;
}
if (!names.contains(currentName.value)) {
currentName.value = names[0];
}
gFFI.dialogManager.show((setState, close, context) {
submit() async {
if (controller.text != gFFI.abModel.translatedName(currentName.value)) {
BotToast.showText(
text: 'illegal address book name: ${controller.text}',
contentColor: Colors.red);
return;
}
isInProgress.value = true;
if (await addTo(currentName.value)) {
close();
}
isInProgress.value = false;
}
cancel() {
close();
}
return CustomAlertDialog(
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(IconFont.addressBook, color: MyTheme.accent),
Text(translate('Add to address book')).paddingOnly(left: 10),
],
),
content: Obx(() => Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// https://github.com/flutter/flutter/issues/145081
DropdownMenu(
initialSelection: currentName.value,
onSelected: (value) {
if (value != null) {
currentName.value = value;
}
},
dropdownMenuEntries: names
.map((e) => DropdownMenuEntry(
value: e, label: gFFI.abModel.translatedName(e)))
.toList(),
inputDecorationTheme: InputDecorationTheme(
isDense: true, border: UnderlineInputBorder()),
enableFilter: true,
controller: controller,
),
// NOT use Offstage to wrap LinearProgressIndicator
isInProgress.value ? const LinearProgressIndicator() : Offstage()
],
)),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: submit,
),
],
onSubmit: submit,
onCancel: cancel,
);
});
}
void setSharedAbPasswordDialog(String abName, Peer peer) {
TextEditingController controller = TextEditingController(text: '');
RxBool isInProgress = false.obs;
RxBool isInputEmpty = true.obs;
bool passwordVisible = false;
controller.addListener(() {
isInputEmpty.value = controller.text.isEmpty;
});
gFFI.dialogManager.show((setState, close, context) {
change(String password) async {
isInProgress.value = true;
bool res =
await gFFI.abModel.changeSharedPassword(abName, peer.id, password);
isInProgress.value = false;
if (res) {
showToast(translate('Successful'));
}
close();
}
cancel() {
close();
}
return CustomAlertDialog(
title: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.key, color: MyTheme.accent),
Text(translate(peer.password.isEmpty
? 'Set shared password'
: 'Change Password'))
.paddingOnly(left: 10),
],
),
content: Obx(() => Column(children: [
TextField(
controller: controller,
autofocus: true,
obscureText: !passwordVisible,
decoration: InputDecoration(
suffixIcon: IconButton(
icon: Icon(
passwordVisible ? Icons.visibility : Icons.visibility_off,
color: MyTheme.lightTheme.primaryColor),
onPressed: () {
setState(() {
passwordVisible = !passwordVisible;
});
},
),
),
),
if (!gFFI.abModel.current.isPersonal())
Row(children: [
Icon(Icons.info, color: Colors.amber).marginOnly(right: 4),
Text(
translate('share_warning_tip'),
style: TextStyle(fontSize: 12),
)
]).marginSymmetric(vertical: 10),
// NOT use Offstage to wrap LinearProgressIndicator
isInProgress.value ? const LinearProgressIndicator() : Offstage()
])),
actions: [
dialogButton(
"Cancel",
icon: Icon(Icons.close_rounded),
onPressed: cancel,
isOutline: true,
),
if (peer.password.isNotEmpty)
dialogButton(
"Remove",
icon: Icon(Icons.delete_outline_rounded),
onPressed: () => change(''),
buttonStyle: ButtonStyle(
backgroundColor: MaterialStatePropertyAll(Colors.red)),
),
Obx(() => dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed:
isInputEmpty.value ? null : () => change(controller.text),
)),
],
onSubmit: isInputEmpty.value ? null : () => change(controller.text),
onCancel: cancel,
);
});
}

View File

@@ -47,7 +47,10 @@ class _MyGroupState extends State<MyGroup> {
err: gFFI.groupModel.groupLoadError, err: gFFI.groupModel.groupLoadError,
retry: null, retry: null,
close: () => gFFI.groupModel.groupLoadError.value = ''), close: () => gFFI.groupModel.groupLoadError.value = ''),
Expanded(child: isDesktop ? _buildDesktop() : _buildMobile()) Expanded(
child: (isDesktop || isWebDesktop)
? _buildDesktop()
: _buildMobile())
], ],
); );
}); });
@@ -83,7 +86,7 @@ class _MyGroupState extends State<MyGroup> {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: MyGroupPeerView( child: MyGroupPeerView(
menuPadding: widget.menuPadding, menuPadding: widget.menuPadding,
initPeers: gFFI.groupModel.peers)), getInitPeers: () => gFFI.groupModel.peers)),
) )
], ],
); );
@@ -115,7 +118,7 @@ class _MyGroupState extends State<MyGroup> {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: MyGroupPeerView( child: MyGroupPeerView(
menuPadding: widget.menuPadding, menuPadding: widget.menuPadding,
initPeers: gFFI.groupModel.peers)), getInitPeers: () => gFFI.groupModel.peers)),
) )
], ],
); );
@@ -164,7 +167,7 @@ class _MyGroupState extends State<MyGroup> {
itemCount: items.length, itemCount: items.length,
itemBuilder: (context, index) => _buildUserItem(items[index])); itemBuilder: (context, index) => _buildUserItem(items[index]));
var maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0); var maxHeight = max(MediaQuery.of(context).size.height / 6, 100.0);
return isDesktop return (isDesktop || isWebDesktop)
? listView ? listView
: LimitedBox(maxHeight: maxHeight, child: listView); : LimitedBox(maxHeight: maxHeight, child: listView);
}); });

View File

@@ -54,7 +54,7 @@ class DraggableChatWindow extends StatelessWidget {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: CustomAppBar( appBar: CustomAppBar(
onPanUpdate: onPanUpdate, onPanUpdate: onPanUpdate,
appBar: isDesktop appBar: (isDesktop || isWebDesktop)
? _buildDesktopAppBar(context) ? _buildDesktopAppBar(context)
: _buildMobileAppBar(context), : _buildMobileAppBar(context),
), ),

View File

@@ -1,5 +1,4 @@
import 'dart:io'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hbb/common/widgets/dialog.dart'; import 'package:flutter_hbb/common/widgets/dialog.dart';
@@ -52,7 +51,7 @@ class _PeerCardState extends State<_PeerCard>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
if (isDesktop) { if (isDesktop || isWebDesktop) {
return _buildDesktop(); return _buildDesktop();
} else { } else {
return _buildMobile(); return _buildMobile();
@@ -70,12 +69,12 @@ class _PeerCardState extends State<_PeerCard>
peerTabModel.select(peer); peerTabModel.select(peer);
} else { } else {
if (!isWebDesktop) { if (!isWebDesktop) {
connectInPeerTab(context, peer.id, widget.tab); connectInPeerTab(context, peer, widget.tab);
} }
} }
}, },
onDoubleTap: isWebDesktop onDoubleTap: isWebDesktop
? () => connectInPeerTab(context, peer.id, widget.tab) ? () => connectInPeerTab(context, peer, widget.tab)
: null, : null,
onLongPress: () { onLongPress: () {
peerTabModel.select(peer); peerTabModel.select(peer);
@@ -140,21 +139,30 @@ class _PeerCardState extends State<_PeerCard>
mainAxisSize: MainAxisSize.max, mainAxisSize: MainAxisSize.max,
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: str2color('${peer.id}${peer.platform}', 0x7f), color: str2color('${peer.id}${peer.platform}', 0x7f),
borderRadius: isMobile borderRadius: isMobile
? BorderRadius.circular(_tileRadius) ? BorderRadius.circular(_tileRadius)
: BorderRadius.only( : BorderRadius.only(
topLeft: Radius.circular(_tileRadius), topLeft: Radius.circular(_tileRadius),
bottomLeft: Radius.circular(_tileRadius), bottomLeft: Radius.circular(_tileRadius),
),
),
alignment: Alignment.center,
width: isMobile ? 50 : 42,
height: isMobile ? 50 : null,
child: Stack(
children: [
getPlatformImage(peer.platform, size: isMobile ? 38 : 30)
.paddingAll(6),
if (_shouldBuildPasswordIcon(peer))
Positioned(
top: 1,
left: 1,
child: Icon(Icons.key, size: 6, color: Colors.white),
), ),
), ],
alignment: Alignment.center, )),
width: isMobile ? 50 : 42,
height: isMobile ? 50 : null,
child: getPlatformImage(peer.platform, size: isMobile ? 38 : 30)
.paddingAll(6),
),
Expanded( Expanded(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -199,8 +207,9 @@ class _PeerCardState extends State<_PeerCard>
) )
], ],
); );
final colors = final colors = _frontN(peer.tags, 25)
_frontN(peer.tags, 25).map((e) => gFFI.abModel.getTagColor(e)).toList(); .map((e) => gFFI.abModel.getCurrentAbTagColor(e))
.toList();
return Tooltip( return Tooltip(
message: isMobile message: isMobile
? '' ? ''
@@ -310,14 +319,21 @@ class _PeerCardState extends State<_PeerCard>
), ),
); );
final colors = final colors = _frontN(peer.tags, 25)
_frontN(peer.tags, 25).map((e) => gFFI.abModel.getTagColor(e)).toList(); .map((e) => gFFI.abModel.getCurrentAbTagColor(e))
.toList();
return Tooltip( return Tooltip(
message: peer.tags.isNotEmpty message: peer.tags.isNotEmpty
? '${translate('Tags')}: ${peer.tags.join(', ')}' ? '${translate('Tags')}: ${peer.tags.join(', ')}'
: '', : '',
child: Stack(children: [ child: Stack(children: [
child, child,
if (_shouldBuildPasswordIcon(peer))
Positioned(
top: 4,
left: 12,
child: Icon(Icons.key, size: 12, color: Colors.white),
),
if (colors.isNotEmpty) if (colors.isNotEmpty)
Positioned( Positioned(
top: 4, top: 4,
@@ -401,6 +417,12 @@ class _PeerCardState extends State<_PeerCard>
onPointerUp: (_) => _showPeerMenu(peer.id), onPointerUp: (_) => _showPeerMenu(peer.id),
child: build_more(context)); child: build_more(context));
bool _shouldBuildPasswordIcon(Peer peer) {
if (gFFI.peerTabModel.currentTab != PeerTabIndex.ab.index) return false;
if (gFFI.abModel.current.isPersonal()) return false;
return peer.password.isNotEmpty;
}
/// Show the peer menu and handle user's choice. /// Show the peer menu and handle user's choice.
/// User might remove the peer or send a file to the peer. /// User might remove the peer or send a file to the peer.
void _showPeerMenu(String id) async { void _showPeerMenu(String id) async {
@@ -431,7 +453,7 @@ abstract class BasePeerCard extends StatelessWidget {
peer: peer, peer: peer,
tab: tab, tab: tab,
connect: (BuildContext context, String id) => connect: (BuildContext context, String id) =>
connectInPeerTab(context, id, tab), connectInPeerTab(context, peer, tab),
popupMenuEntryBuilder: _buildPopupMenuEntry, popupMenuEntryBuilder: _buildPopupMenuEntry,
); );
} }
@@ -453,7 +475,6 @@ abstract class BasePeerCard extends StatelessWidget {
MenuEntryBase<String> _connectCommonAction( MenuEntryBase<String> _connectCommonAction(
BuildContext context, BuildContext context,
String id,
String title, { String title, {
bool isFileTransfer = false, bool isFileTransfer = false,
bool isTcpTunneling = false, bool isTcpTunneling = false,
@@ -467,7 +488,7 @@ abstract class BasePeerCard extends StatelessWidget {
proc: () { proc: () {
connectInPeerTab( connectInPeerTab(
context, context,
peer.id, peer,
tab, tab,
isFileTransfer: isFileTransfer, isFileTransfer: isFileTransfer,
isTcpTunneling: isTcpTunneling, isTcpTunneling: isTcpTunneling,
@@ -480,10 +501,9 @@ abstract class BasePeerCard extends StatelessWidget {
} }
@protected @protected
MenuEntryBase<String> _connectAction(BuildContext context, Peer peer) { MenuEntryBase<String> _connectAction(BuildContext context) {
return _connectCommonAction( return _connectCommonAction(
context, context,
peer.id,
(peer.alias.isEmpty (peer.alias.isEmpty
? translate('Connect') ? translate('Connect')
: '${translate('Connect')} ${peer.id}'), : '${translate('Connect')} ${peer.id}'),
@@ -491,20 +511,18 @@ abstract class BasePeerCard extends StatelessWidget {
} }
@protected @protected
MenuEntryBase<String> _transferFileAction(BuildContext context, String id) { MenuEntryBase<String> _transferFileAction(BuildContext context) {
return _connectCommonAction( return _connectCommonAction(
context, context,
id,
translate('Transfer file'), translate('Transfer file'),
isFileTransfer: true, isFileTransfer: true,
); );
} }
@protected @protected
MenuEntryBase<String> _tcpTunnelingAction(BuildContext context, String id) { MenuEntryBase<String> _tcpTunnelingAction(BuildContext context) {
return _connectCommonAction( return _connectCommonAction(
context, context,
id,
translate('TCP tunneling'), translate('TCP tunneling'),
isTcpTunneling: true, isTcpTunneling: true,
); );
@@ -541,7 +559,7 @@ abstract class BasePeerCard extends StatelessWidget {
], ],
)), )),
proc: () { proc: () {
connectInPeerTab(context, id, tab, isRDP: true); connectInPeerTab(context, peer, tab, isRDP: true);
}, },
padding: menuPadding, padding: menuPadding,
dismissOnClicked: true, dismissOnClicked: true,
@@ -648,9 +666,8 @@ abstract class BasePeerCard extends StatelessWidget {
onSubmit: (String newName) async { onSubmit: (String newName) async {
if (newName != oldName) { if (newName != oldName) {
if (tab == PeerTabIndex.ab) { if (tab == PeerTabIndex.ab) {
gFFI.abModel.changeAlias(id: id, alias: newName); await gFFI.abModel.changeAlias(id: id, alias: newName);
await bind.mainSetPeerAlias(id: id, alias: newName); await bind.mainSetPeerAlias(id: id, alias: newName);
gFFI.abModel.pushAb();
} else { } else {
await bind.mainSetPeerAlias(id: id, alias: newName); await bind.mainSetPeerAlias(id: id, alias: newName);
showToast(translate('Successful')); showToast(translate('Successful'));
@@ -702,11 +719,7 @@ abstract class BasePeerCard extends StatelessWidget {
await bind.mainLoadLanPeers(); await bind.mainLoadLanPeers();
break; break;
case PeerTabIndex.ab: case PeerTabIndex.ab:
gFFI.abModel.deletePeer(id); await gFFI.abModel.deletePeers([id]);
final future = gFFI.abModel.pushAb();
if (await bind.mainPeerExists(id: peer.id)) {
gFFI.abModel.reSyncToast(future);
}
break; break;
case PeerTabIndex.group: case PeerTabIndex.group:
break; break;
@@ -716,7 +729,7 @@ abstract class BasePeerCard extends StatelessWidget {
} }
} }
deletePeerConfirmDialog(onSubmit, deleteConfirmDialog(onSubmit,
'${translate('Delete')} "${peer.alias.isEmpty ? formatID(peer.id) : peer.alias}"?'); '${translate('Delete')} "${peer.alias.isEmpty ? formatID(peer.id) : peer.alias}"?');
}, },
padding: menuPadding, padding: menuPadding,
@@ -732,14 +745,16 @@ abstract class BasePeerCard extends StatelessWidget {
style: style, style: style,
), ),
proc: () async { proc: () async {
bool result = gFFI.abModel.changePassword(id, ''); bool succ = await gFFI.abModel.changePersonalHashPassword(id, '');
await bind.mainForgetPassword(id: id); await bind.mainForgetPassword(id: id);
bool toast = false; if (succ) {
if (result) { showToast(translate('Successful'));
toast = tab == PeerTabIndex.ab; } else {
gFFI.abModel.pushAb(toastIfFail: toast, toastIfSucc: toast); if (tab.index == PeerTabIndex.ab.index) {
BotToast.showText(
contentColor: Colors.red, text: translate("Failed"));
}
} }
if (!toast) showToast(translate('Successful'));
}, },
padding: menuPadding, padding: menuPadding,
dismissOnClicked: true, dismissOnClicked: true,
@@ -824,13 +839,7 @@ abstract class BasePeerCard extends StatelessWidget {
), ),
proc: () { proc: () {
() async { () async {
if (gFFI.abModel.isFull(true)) { addPeersToAbDialog([Peer.copy(peer)]);
return;
}
if (!gFFI.abModel.idContainBy(peer.id)) {
gFFI.abModel.addPeer(peer);
gFFI.abModel.pushAb();
}
}(); }();
}, },
padding: menuPadding, padding: menuPadding,
@@ -858,25 +867,29 @@ class RecentPeerCard extends BasePeerCard {
Future<List<MenuEntryBase<String>>> _buildMenuItems( Future<List<MenuEntryBase<String>>> _buildMenuItems(
BuildContext context) async { BuildContext context) async {
final List<MenuEntryBase<String>> menuItems = [ final List<MenuEntryBase<String>> menuItems = [
_connectAction(context, peer), _connectAction(context),
_transferFileAction(context, peer.id), if (!isWeb) _transferFileAction(context),
]; ];
final List favs = (await bind.mainGetFav()).toList(); final List favs = (await bind.mainGetFav()).toList();
if (isDesktop && peer.platform != kPeerPlatformAndroid) { if (isDesktop && peer.platform != kPeerPlatformAndroid) {
menuItems.add(_tcpTunnelingAction(context, peer.id)); menuItems.add(_tcpTunnelingAction(context));
} }
// menuItems.add(await _openNewConnInOptAction(peer.id)); // menuItems.add(await _openNewConnInOptAction(peer.id));
menuItems.add(await _forceAlwaysRelayAction(peer.id)); if (!isWeb) {
if (Platform.isWindows && peer.platform == kPeerPlatformWindows) { menuItems.add(await _forceAlwaysRelayAction(peer.id));
}
if (isWindows && peer.platform == kPeerPlatformWindows) {
menuItems.add(_rdpAction(context, peer.id)); menuItems.add(_rdpAction(context, peer.id));
} }
if (Platform.isWindows) { if (isWindows) {
menuItems.add(_createShortCutAction(peer.id)); menuItems.add(_createShortCutAction(peer.id));
} }
menuItems.add(MenuEntryDivider()); menuItems.add(MenuEntryDivider());
menuItems.add(_renameAction(peer.id)); if (isDesktop || isWebDesktop) {
menuItems.add(_renameAction(peer.id));
}
if (await bind.mainPeerHasPassword(id: peer.id)) { if (await bind.mainPeerHasPassword(id: peer.id)) {
menuItems.add(_unrememberPasswordAction(peer.id)); menuItems.add(_unrememberPasswordAction(peer.id));
} }
@@ -888,9 +901,7 @@ class RecentPeerCard extends BasePeerCard {
} }
if (gFFI.userModel.userName.isNotEmpty) { if (gFFI.userModel.userName.isNotEmpty) {
if (!gFFI.abModel.idContainBy(peer.id)) { menuItems.add(_addToAb(peer));
menuItems.add(_addToAb(peer));
}
} }
menuItems.add(MenuEntryDivider()); menuItems.add(MenuEntryDivider());
@@ -915,22 +926,26 @@ class FavoritePeerCard extends BasePeerCard {
Future<List<MenuEntryBase<String>>> _buildMenuItems( Future<List<MenuEntryBase<String>>> _buildMenuItems(
BuildContext context) async { BuildContext context) async {
final List<MenuEntryBase<String>> menuItems = [ final List<MenuEntryBase<String>> menuItems = [
_connectAction(context, peer), _connectAction(context),
_transferFileAction(context, peer.id), if (!isWeb) _transferFileAction(context),
]; ];
if (isDesktop && peer.platform != kPeerPlatformAndroid) { if (isDesktop && peer.platform != kPeerPlatformAndroid) {
menuItems.add(_tcpTunnelingAction(context, peer.id)); menuItems.add(_tcpTunnelingAction(context));
} }
// menuItems.add(await _openNewConnInOptAction(peer.id)); // menuItems.add(await _openNewConnInOptAction(peer.id));
menuItems.add(await _forceAlwaysRelayAction(peer.id)); if (!isWeb) {
if (Platform.isWindows && peer.platform == kPeerPlatformWindows) { menuItems.add(await _forceAlwaysRelayAction(peer.id));
}
if (isWindows && peer.platform == kPeerPlatformWindows) {
menuItems.add(_rdpAction(context, peer.id)); menuItems.add(_rdpAction(context, peer.id));
} }
if (Platform.isWindows) { if (isWindows) {
menuItems.add(_createShortCutAction(peer.id)); menuItems.add(_createShortCutAction(peer.id));
} }
menuItems.add(MenuEntryDivider()); menuItems.add(MenuEntryDivider());
menuItems.add(_renameAction(peer.id)); if (isDesktop || isWebDesktop) {
menuItems.add(_renameAction(peer.id));
}
if (await bind.mainPeerHasPassword(id: peer.id)) { if (await bind.mainPeerHasPassword(id: peer.id)) {
menuItems.add(_unrememberPasswordAction(peer.id)); menuItems.add(_unrememberPasswordAction(peer.id));
} }
@@ -939,9 +954,7 @@ class FavoritePeerCard extends BasePeerCard {
})); }));
if (gFFI.userModel.userName.isNotEmpty) { if (gFFI.userModel.userName.isNotEmpty) {
if (!gFFI.abModel.idContainBy(peer.id)) { menuItems.add(_addToAb(peer));
menuItems.add(_addToAb(peer));
}
} }
menuItems.add(MenuEntryDivider()); menuItems.add(MenuEntryDivider());
@@ -966,22 +979,24 @@ class DiscoveredPeerCard extends BasePeerCard {
Future<List<MenuEntryBase<String>>> _buildMenuItems( Future<List<MenuEntryBase<String>>> _buildMenuItems(
BuildContext context) async { BuildContext context) async {
final List<MenuEntryBase<String>> menuItems = [ final List<MenuEntryBase<String>> menuItems = [
_connectAction(context, peer), _connectAction(context),
_transferFileAction(context, peer.id), if (!isWeb) _transferFileAction(context),
]; ];
final List favs = (await bind.mainGetFav()).toList(); final List favs = (await bind.mainGetFav()).toList();
if (isDesktop && peer.platform != kPeerPlatformAndroid) { if (isDesktop && peer.platform != kPeerPlatformAndroid) {
menuItems.add(_tcpTunnelingAction(context, peer.id)); menuItems.add(_tcpTunnelingAction(context));
} }
// menuItems.add(await _openNewConnInOptAction(peer.id)); // menuItems.add(await _openNewConnInOptAction(peer.id));
menuItems.add(await _forceAlwaysRelayAction(peer.id)); if (!isWeb) {
if (Platform.isWindows && peer.platform == kPeerPlatformWindows) { menuItems.add(await _forceAlwaysRelayAction(peer.id));
}
if (isWindows && peer.platform == kPeerPlatformWindows) {
menuItems.add(_rdpAction(context, peer.id)); menuItems.add(_rdpAction(context, peer.id));
} }
menuItems.add(_wolAction(peer.id)); menuItems.add(_wolAction(peer.id));
if (Platform.isWindows) { if (isWindows) {
menuItems.add(_createShortCutAction(peer.id)); menuItems.add(_createShortCutAction(peer.id));
} }
@@ -992,9 +1007,7 @@ class DiscoveredPeerCard extends BasePeerCard {
} }
if (gFFI.userModel.userName.isNotEmpty) { if (gFFI.userModel.userName.isNotEmpty) {
if (!gFFI.abModel.idContainBy(peer.id)) { menuItems.add(_addToAb(peer));
menuItems.add(_addToAb(peer));
}
} }
menuItems.add(MenuEntryDivider()); menuItems.add(MenuEntryDivider());
@@ -1019,37 +1032,55 @@ class AddressBookPeerCard extends BasePeerCard {
Future<List<MenuEntryBase<String>>> _buildMenuItems( Future<List<MenuEntryBase<String>>> _buildMenuItems(
BuildContext context) async { BuildContext context) async {
final List<MenuEntryBase<String>> menuItems = [ final List<MenuEntryBase<String>> menuItems = [
_connectAction(context, peer), _connectAction(context),
_transferFileAction(context, peer.id), if (!isWeb) _transferFileAction(context),
]; ];
if (isDesktop && peer.platform != kPeerPlatformAndroid) { if (isDesktop && peer.platform != kPeerPlatformAndroid) {
menuItems.add(_tcpTunnelingAction(context, peer.id)); menuItems.add(_tcpTunnelingAction(context));
} }
// menuItems.add(await _openNewConnInOptAction(peer.id)); // menuItems.add(await _openNewConnInOptAction(peer.id));
menuItems.add(await _forceAlwaysRelayAction(peer.id)); // menuItems.add(await _forceAlwaysRelayAction(peer.id));
if (Platform.isWindows && peer.platform == kPeerPlatformWindows) { if (isWindows && peer.platform == kPeerPlatformWindows) {
menuItems.add(_rdpAction(context, peer.id)); menuItems.add(_rdpAction(context, peer.id));
} }
if (Platform.isWindows) { if (isWindows) {
menuItems.add(_createShortCutAction(peer.id)); menuItems.add(_createShortCutAction(peer.id));
} }
menuItems.add(MenuEntryDivider()); if (gFFI.abModel.current.canWrite()) {
menuItems.add(_renameAction(peer.id)); menuItems.add(MenuEntryDivider());
if (peer.hash.isNotEmpty) { if (isDesktop || isWebDesktop) {
menuItems.add(_unrememberPasswordAction(peer.id)); menuItems.add(_renameAction(peer.id));
}
if (gFFI.abModel.current.isPersonal() && peer.hash.isNotEmpty) {
menuItems.add(_unrememberPasswordAction(peer.id));
}
if (!gFFI.abModel.current.isPersonal()) {
menuItems.add(_changeSharedAbPassword());
}
if (gFFI.abModel.currentAbTags.isNotEmpty) {
menuItems.add(_editTagAction(peer.id));
}
} }
if (gFFI.abModel.tags.isNotEmpty) { final addressbooks = gFFI.abModel.addressBooksCanWrite();
menuItems.add(_editTagAction(peer.id)); if (gFFI.peerTabModel.currentTab == PeerTabIndex.ab.index) {
addressbooks.remove(gFFI.abModel.currentName.value);
}
if (addressbooks.isNotEmpty) {
menuItems.add(_addToAb(peer));
}
menuItems.add(_existIn());
if (gFFI.abModel.current.canWrite()) {
menuItems.add(MenuEntryDivider());
menuItems.add(_removeAction(peer.id));
} }
menuItems.add(MenuEntryDivider());
menuItems.add(_removeAction(peer.id));
return menuItems; return menuItems;
} }
// address book does not need to update
@protected @protected
@override @override
void _update() => gFFI.abModel.pullAb(quiet: true); void _update() =>
{}; //gFFI.abModel.pullAb(force: ForcePullAb.current, quiet: true);
@protected @protected
MenuEntryBase<String> _editTagAction(String id) { MenuEntryBase<String> _editTagAction(String id) {
@@ -1060,8 +1091,7 @@ class AddressBookPeerCard extends BasePeerCard {
), ),
proc: () { proc: () {
editAbTagDialog(gFFI.abModel.getPeerTags(id), (selectedTag) async { editAbTagDialog(gFFI.abModel.getPeerTags(id), (selectedTag) async {
gFFI.abModel.changeTagForPeer(id, selectedTag); await gFFI.abModel.changeTagForPeers([id], selectedTag);
gFFI.abModel.pushAb();
}); });
}, },
padding: super.menuPadding, padding: super.menuPadding,
@@ -1073,6 +1103,53 @@ class AddressBookPeerCard extends BasePeerCard {
@override @override
Future<String> _getAlias(String id) async => Future<String> _getAlias(String id) async =>
gFFI.abModel.find(id)?.alias ?? ''; gFFI.abModel.find(id)?.alias ?? '';
MenuEntryBase<String> _changeSharedAbPassword() {
return MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text(
translate(
peer.password.isEmpty ? 'Set shared password' : 'Change Password'),
style: style,
),
proc: () {
setSharedAbPasswordDialog(gFFI.abModel.currentName.value, peer);
},
padding: super.menuPadding,
dismissOnClicked: true,
);
}
MenuEntryBase<String> _existIn() {
final names = gFFI.abModel.idExistIn(peer.id);
final text = names.join(', ');
return MenuEntryButton<String>(
childBuilder: (TextStyle? style) => Text(
translate('Exist in'),
style: style,
),
proc: () {
gFFI.dialogManager.show((setState, close, context) {
return CustomAlertDialog(
title: Text(translate('Exist in')),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [Text(text)]),
actions: [
dialogButton(
"OK",
icon: Icon(Icons.done_rounded),
onPressed: close,
),
],
onSubmit: close,
onCancel: close,
);
});
},
padding: super.menuPadding,
dismissOnClicked: true,
);
}
} }
class MyGroupPeerCard extends BasePeerCard { class MyGroupPeerCard extends BasePeerCard {
@@ -1087,18 +1164,18 @@ class MyGroupPeerCard extends BasePeerCard {
Future<List<MenuEntryBase<String>>> _buildMenuItems( Future<List<MenuEntryBase<String>>> _buildMenuItems(
BuildContext context) async { BuildContext context) async {
final List<MenuEntryBase<String>> menuItems = [ final List<MenuEntryBase<String>> menuItems = [
_connectAction(context, peer), _connectAction(context),
_transferFileAction(context, peer.id), if (!isWeb) _transferFileAction(context),
]; ];
if (isDesktop && peer.platform != kPeerPlatformAndroid) { if (isDesktop && peer.platform != kPeerPlatformAndroid) {
menuItems.add(_tcpTunnelingAction(context, peer.id)); menuItems.add(_tcpTunnelingAction(context));
} }
// menuItems.add(await _openNewConnInOptAction(peer.id)); // menuItems.add(await _openNewConnInOptAction(peer.id));
// menuItems.add(await _forceAlwaysRelayAction(peer.id)); // menuItems.add(await _forceAlwaysRelayAction(peer.id));
if (Platform.isWindows && peer.platform == kPeerPlatformWindows) { if (isWindows && peer.platform == kPeerPlatformWindows) {
menuItems.add(_rdpAction(context, peer.id)); menuItems.add(_rdpAction(context, peer.id));
} }
if (Platform.isWindows) { if (isWindows) {
menuItems.add(_createShortCutAction(peer.id)); menuItems.add(_createShortCutAction(peer.id));
} }
// menuItems.add(MenuEntryDivider()); // menuItems.add(MenuEntryDivider());
@@ -1107,9 +1184,7 @@ class MyGroupPeerCard extends BasePeerCard {
// menuItems.add(_unrememberPasswordAction(peer.id)); // menuItems.add(_unrememberPasswordAction(peer.id));
// } // }
if (gFFI.userModel.userName.isNotEmpty) { if (gFFI.userModel.userName.isNotEmpty) {
if (!gFFI.abModel.idContainBy(peer.id)) { menuItems.add(_addToAb(peer));
menuItems.add(_addToAb(peer));
}
} }
return menuItems; return menuItems;
} }
@@ -1176,7 +1251,7 @@ void _rdpDialog(String id) async {
).marginOnly(bottom: isDesktop ? 8 : 0), ).marginOnly(bottom: isDesktop ? 8 : 0),
Row( Row(
children: [ children: [
isDesktop (isDesktop || isWebDesktop)
? ConstrainedBox( ? ConstrainedBox(
constraints: const BoxConstraints(minWidth: 140), constraints: const BoxConstraints(minWidth: 140),
child: Text( child: Text(
@@ -1187,15 +1262,17 @@ void _rdpDialog(String id) async {
Expanded( Expanded(
child: TextField( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
labelText: isDesktop ? null : translate('Username')), labelText: (isDesktop || isWebDesktop)
? null
: translate('Username')),
controller: userController, controller: userController,
), ),
), ),
], ],
).marginOnly(bottom: isDesktop ? 8 : 0), ).marginOnly(bottom: (isDesktop || isWebDesktop) ? 8 : 0),
Row( Row(
children: [ children: [
isDesktop (isDesktop || isWebDesktop)
? ConstrainedBox( ? ConstrainedBox(
constraints: const BoxConstraints(minWidth: 140), constraints: const BoxConstraints(minWidth: 140),
child: Text( child: Text(
@@ -1207,7 +1284,9 @@ void _rdpDialog(String id) async {
child: Obx(() => TextField( child: Obx(() => TextField(
obscureText: secure.value, obscureText: secure.value,
decoration: InputDecoration( decoration: InputDecoration(
labelText: isDesktop ? null : translate('Password'), labelText: (isDesktop || isWebDesktop)
? null
: translate('Password'),
suffixIcon: IconButton( suffixIcon: IconButton(
onPressed: () => secure.value = !secure.value, onPressed: () => secure.value = !secure.value,
icon: Icon(secure.value icon: Icon(secure.value
@@ -1305,24 +1384,32 @@ class TagPainter extends CustomPainter {
} }
} }
void connectInPeerTab(BuildContext context, String id, PeerTabIndex tab, void connectInPeerTab(BuildContext context, Peer peer, PeerTabIndex tab,
{bool isFileTransfer = false, {bool isFileTransfer = false,
bool isTcpTunneling = false, bool isTcpTunneling = false,
bool isRDP = false}) async { bool isRDP = false}) async {
var password = '';
bool isSharedPassword = false;
if (tab == PeerTabIndex.ab) { if (tab == PeerTabIndex.ab) {
// If recent peer's alias is empty, set it to ab's alias // If recent peer's alias is empty, set it to ab's alias
// Because the platform is not set, it may not take effect, but it is more important not to display if the connection is not successful // Because the platform is not set, it may not take effect, but it is more important not to display if the connection is not successful
Peer? p = gFFI.abModel.find(id); if (peer.alias.isNotEmpty &&
if (p != null && (await bind.mainGetPeerOption(id: peer.id, key: "alias")).isEmpty) {
p.alias.isNotEmpty &&
(await bind.mainGetPeerOption(id: id, key: "alias")).isEmpty) {
await bind.mainSetPeerAlias( await bind.mainSetPeerAlias(
id: id, id: peer.id,
alias: p.alias, alias: peer.alias,
); );
} }
if (!gFFI.abModel.current.isPersonal()) {
if (peer.password.isNotEmpty) {
password = peer.password;
isSharedPassword = true;
}
}
} }
connect(context, id, connect(context, peer.id,
password: password,
isSharedPassword: isSharedPassword,
isFileTransfer: isFileTransfer, isFileTransfer: isFileTransfer,
isTcpTunneling: isTcpTunneling, isTcpTunneling: isTcpTunneling,
isRDP: isRDP); isRDP: isRDP);

View File

@@ -13,6 +13,7 @@ import 'package:flutter_hbb/desktop/widgets/material_mod_popup_menu.dart'
as mod_menu; as mod_menu;
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart'; import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/models/ab_model.dart'; import 'package:flutter_hbb/models/ab_model.dart';
import 'package:flutter_hbb/models/peer_model.dart';
import 'package:flutter_hbb/models/peer_tab_model.dart'; import 'package:flutter_hbb/models/peer_tab_model.dart';
import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/flutter_svg.dart';
@@ -36,7 +37,7 @@ class _TabEntry {
} }
EdgeInsets? _menuPadding() { EdgeInsets? _menuPadding() {
return isDesktop ? kDesktopMenuPadding : null; return (isDesktop || isWebDesktop) ? kDesktopMenuPadding : null;
} }
class _PeerTabPageState extends State<PeerTabPage> class _PeerTabPageState extends State<PeerTabPage>
@@ -61,7 +62,9 @@ class _PeerTabPageState extends State<PeerTabPage>
AddressBook( AddressBook(
menuPadding: _menuPadding(), menuPadding: _menuPadding(),
), ),
({dynamic hint}) => gFFI.abModel.pullAb(force: hint == null)), ({dynamic hint}) => gFFI.abModel.pullAb(
force: hint == null ? ForcePullAb.listAndCurrent : null,
quiet: false)),
_TabEntry( _TabEntry(
MyGroup( MyGroup(
menuPadding: _menuPadding(), menuPadding: _menuPadding(),
@@ -110,7 +113,9 @@ class _PeerTabPageState extends State<PeerTabPage>
SizedBox( SizedBox(
height: 32, height: 32,
child: Container( child: Container(
padding: isDesktop ? null : EdgeInsets.symmetric(horizontal: 2), padding: (isDesktop || isWebDesktop)
? null
: EdgeInsets.symmetric(horizontal: 2),
child: selectionWrap(Row( child: selectionWrap(Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
@@ -124,7 +129,7 @@ class _PeerTabPageState extends State<PeerTabPage>
], ],
)), )),
), ),
).paddingOnly(right: isDesktop ? 12 : 0), ).paddingOnly(right: (isDesktop || isWebDesktop) ? 12 : 0),
_createPeersView(), _createPeersView(),
], ],
); );
@@ -132,11 +137,13 @@ class _PeerTabPageState extends State<PeerTabPage>
Widget _createSwitchBar(BuildContext context) { Widget _createSwitchBar(BuildContext context) {
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
var counter = -1;
return ListView( return ReorderableListView(
buildDefaultDragHandles: false,
onReorder: model.reorder,
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
children: model.visibleIndexs.map((t) { children: model.visibleEnabledOrderedIndexs.map((t) {
final selected = model.currentTab == t; final selected = model.currentTab == t;
final color = selected final color = selected
? MyTheme.tabbar(context).selectedTextColor ? MyTheme.tabbar(context).selectedTextColor
@@ -150,48 +157,54 @@ class _PeerTabPageState extends State<PeerTabPage>
border: Border( border: Border(
bottom: BorderSide(width: 2, color: color!), bottom: BorderSide(width: 2, color: color!),
)); ));
return Obx(() => InkWell( counter += 1;
child: Container( return ReorderableDragStartListener(
decoration: (hover.value key: ValueKey(t),
? (selected ? decoBorder : deco) index: counter,
: (selected ? decoBorder : null)), child: Obx(() => Tooltip(
child: Tooltip(
preferBelow: false, preferBelow: false,
message: model.tabTooltip(t), message: model.tabTooltip(t),
onTriggered: isMobile ? mobileShowTabVisibilityMenu : null, onTriggered: isMobile ? mobileShowTabVisibilityMenu : null,
child: Icon(model.tabIcon(t), color: color), child: InkWell(
).paddingSymmetric(horizontal: 4), child: Container(
).paddingSymmetric(horizontal: 4), decoration: (hover.value
onTap: () async { ? (selected ? decoBorder : deco)
await handleTabSelection(t); : (selected ? decoBorder : null)),
await bind.setLocalFlutterOption( child: Icon(model.tabIcon(t), color: color)
k: 'peer-tab-index', v: t.toString()); .paddingSymmetric(horizontal: 4),
}, ).paddingSymmetric(horizontal: 4),
onHover: (value) => hover.value = value, onTap: () async {
)); await handleTabSelection(t);
await bind.setLocalFlutterOption(
k: PeerTabModel.kPeerTabIndex, v: t.toString());
},
onHover: (value) => hover.value = value,
),
)));
}).toList()); }).toList());
} }
Widget _createPeersView() { Widget _createPeersView() {
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
Widget child; Widget child;
if (model.visibleIndexs.isEmpty) { if (model.visibleEnabledOrderedIndexs.isEmpty) {
child = visibleContextMenuListener(Row( child = visibleContextMenuListener(Row(
children: [Expanded(child: InkWell())], children: [Expanded(child: InkWell())],
)); ));
} else { } else {
if (model.visibleIndexs.contains(model.currentTab)) { if (model.visibleEnabledOrderedIndexs.contains(model.currentTab)) {
child = entries[model.currentTab].widget; child = entries[model.currentTab].widget;
} else { } else {
debugPrint("should not happen! currentTab not in visibleIndexs"); debugPrint("should not happen! currentTab not in visibleIndexs");
Future.delayed(Duration.zero, () { Future.delayed(Duration.zero, () {
model.setCurrentTab(model.indexs[0]); model.setCurrentTab(model.visibleEnabledOrderedIndexs[0]);
}); });
child = entries[0].widget; child = entries[0].widget;
} }
} }
return Expanded( return Expanded(
child: child.marginSymmetric(vertical: isDesktop ? 12.0 : 6.0)); child: child.marginSymmetric(
vertical: (isDesktop || isWebDesktop) ? 12.0 : 6.0));
} }
Widget _createRefresh( Widget _createRefresh(
@@ -200,22 +213,23 @@ class _PeerTabPageState extends State<PeerTabPage>
final textColor = Theme.of(context).textTheme.titleLarge?.color; final textColor = Theme.of(context).textTheme.titleLarge?.color;
return Offstage( return Offstage(
offstage: model.currentTab != index.index, offstage: model.currentTab != index.index,
child: RefreshWidget( child: Tooltip(
onPressed: () { message: translate('Refresh'),
if (gFFI.peerTabModel.currentTab < entries.length) { child: RefreshWidget(
entries[gFFI.peerTabModel.currentTab].load(); onPressed: () {
} if (gFFI.peerTabModel.currentTab < entries.length) {
}, entries[gFFI.peerTabModel.currentTab].load();
spinning: loading, }
child: RotatedBox( },
quarterTurns: 2, spinning: loading,
child: Tooltip( child: RotatedBox(
message: translate('Refresh'), quarterTurns: 2,
child: Icon( child: Icon(
Icons.refresh, Icons.refresh,
size: 18, size: 18,
color: textColor, color: textColor,
)))), ))),
),
); );
} }
@@ -227,6 +241,7 @@ class _PeerTabPageState extends State<PeerTabPage>
final textColor = Theme.of(context).textTheme.titleLarge?.color; final textColor = Theme.of(context).textTheme.titleLarge?.color;
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
return _hoverAction( return _hoverAction(
toolTip: translate('Select'),
context: context, context: context,
onTap: () { onTap: () {
model.setMultiSelectionMode(true); model.setMultiSelectionMode(true);
@@ -234,30 +249,29 @@ class _PeerTabPageState extends State<PeerTabPage>
Navigator.pop(context); Navigator.pop(context);
} }
}, },
child: Tooltip( child: SvgPicture.asset(
message: translate('Select'), "assets/checkbox-outline.svg",
child: SvgPicture.asset( width: 18,
"assets/checkbox-outline.svg", height: 18,
width: 18, colorFilter: svgColor(textColor),
height: 18, ),
colorFilter: svgColor(textColor),
)),
); );
} }
void mobileShowTabVisibilityMenu() { void mobileShowTabVisibilityMenu() {
final model = gFFI.peerTabModel; final model = gFFI.peerTabModel;
final items = List<PopupMenuItem>.empty(growable: true); final items = List<PopupMenuItem>.empty(growable: true);
for (int i = 0; i < model.tabNames.length; i++) { for (int i = 0; i < PeerTabModel.maxTabCount; i++) {
if (!model.isEnabled[i]) continue;
items.add(PopupMenuItem( items.add(PopupMenuItem(
height: kMinInteractiveDimension * 0.8, height: kMinInteractiveDimension * 0.8,
onTap: () => model.setTabVisible(i, !model.isVisible[i]), onTap: () => model.setTabVisible(i, !model.isVisibleEnabled[i]),
child: Row( child: Row(
children: [ children: [
Checkbox( Checkbox(
value: model.isVisible[i], value: model.isVisibleEnabled[i],
onChanged: (_) { onChanged: (_) {
model.setTabVisible(i, !model.isVisible[i]); model.setTabVisible(i, !model.isVisibleEnabled[i]);
if (Navigator.canPop(context)) { if (Navigator.canPop(context)) {
Navigator.pop(context); Navigator.pop(context);
} }
@@ -307,16 +321,17 @@ class _PeerTabPageState extends State<PeerTabPage>
Widget visibleContextMenu(CancelFunc cancelFunc) { Widget visibleContextMenu(CancelFunc cancelFunc) {
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
final menu = List<MenuEntrySwitch>.empty(growable: true); final menu = List<MenuEntrySwitchSync>.empty(growable: true);
for (int i = 0; i < model.tabNames.length; i++) { for (int i = 0; i < model.orders.length; i++) {
menu.add(MenuEntrySwitch( int tabIndex = model.orders[i];
if (tabIndex < 0 || tabIndex >= PeerTabModel.maxTabCount) continue;
if (!model.isEnabled[tabIndex]) continue;
menu.add(MenuEntrySwitchSync(
switchType: SwitchType.scheckbox, switchType: SwitchType.scheckbox,
text: model.tabTooltip(i), text: model.tabTooltip(tabIndex),
getter: () async { currentValue: model.isVisibleEnabled[tabIndex],
return model.isVisible[i];
},
setter: (show) async { setter: (show) async {
model.setTabVisible(i, show); model.setTabVisible(tabIndex, show);
cancelFunc(); cancelFunc();
})); }));
} }
@@ -367,6 +382,7 @@ class _PeerTabPageState extends State<PeerTabPage>
} }
return _hoverAction( return _hoverAction(
context: context, context: context,
toolTip: translate('Delete'),
onTap: () { onTap: () {
onSubmit() async { onSubmit() async {
final peers = model.selectedPeers; final peers = model.selectedPeers;
@@ -392,21 +408,7 @@ class _PeerTabPageState extends State<PeerTabPage>
await bind.mainLoadLanPeers(); await bind.mainLoadLanPeers();
break; break;
case 3: case 3:
{ await gFFI.abModel.deletePeers(peers.map((p) => p.id).toList());
bool hasSynced = false;
if (shouldSyncAb()) {
for (var p in peers) {
if (await bind.mainPeerExists(id: p.id)) {
hasSynced = true;
}
}
}
gFFI.abModel.deletePeers(peers.map((p) => p.id).toList());
final future = gFFI.abModel.pushAb();
if (hasSynced) {
gFFI.abModel.reSyncToast(future);
}
}
break; break;
default: default:
break; break;
@@ -415,11 +417,9 @@ class _PeerTabPageState extends State<PeerTabPage>
if (model.currentTab != 3) showToast(translate('Successful')); if (model.currentTab != 3) showToast(translate('Successful'));
} }
deletePeerConfirmDialog(onSubmit, translate('Delete')); deleteConfirmDialog(onSubmit, translate('Delete'));
}, },
child: Tooltip( child: Icon(Icons.delete, color: Colors.red));
message: translate('Delete'),
child: Icon(Icons.delete, color: Colors.red)));
} }
Widget addSelectionToFav() { Widget addSelectionToFav() {
@@ -429,6 +429,7 @@ class _PeerTabPageState extends State<PeerTabPage>
model.currentTab != PeerTabIndex.recent.index, // show based on recent model.currentTab != PeerTabIndex.recent.index, // show based on recent
child: _hoverAction( child: _hoverAction(
context: context, context: context,
toolTip: translate('Add to Favorites'),
onTap: () async { onTap: () async {
final peers = model.selectedPeers; final peers = model.selectedPeers;
final favs = (await bind.mainGetFav()).toList(); final favs = (await bind.mainGetFav()).toList();
@@ -441,37 +442,28 @@ class _PeerTabPageState extends State<PeerTabPage>
model.setMultiSelectionMode(false); model.setMultiSelectionMode(false);
showToast(translate('Successful')); showToast(translate('Successful'));
}, },
child: Tooltip( child: Icon(PeerTabModel.icons[PeerTabIndex.fav.index]),
message: translate('Add to Favorites'),
child: Icon(model.icons[PeerTabIndex.fav.index])),
).marginOnly(left: isMobile ? 11 : 6), ).marginOnly(left: isMobile ? 11 : 6),
); );
} }
Widget addSelectionToAb() { Widget addSelectionToAb() {
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
final addressbooks = gFFI.abModel.addressBooksCanWrite();
if (model.currentTab == PeerTabIndex.ab.index) {
addressbooks.remove(gFFI.abModel.currentName.value);
}
return Offstage( return Offstage(
offstage: offstage: !gFFI.userModel.isLogin || addressbooks.isEmpty,
!gFFI.userModel.isLogin || model.currentTab == PeerTabIndex.ab.index,
child: _hoverAction( child: _hoverAction(
context: context, context: context,
toolTip: translate('Add to address book'),
onTap: () { onTap: () {
if (gFFI.abModel.isFull(true)) { final peers = model.selectedPeers.map((e) => Peer.copy(e)).toList();
return; addPeersToAbDialog(peers);
}
final peers = model.selectedPeers;
gFFI.abModel.addPeers(peers);
final future = gFFI.abModel.pushAb();
model.setMultiSelectionMode(false); model.setMultiSelectionMode(false);
Future.delayed(Duration.zero, () async {
await future;
await Future.delayed(Duration(seconds: 2)); // toast
gFFI.abModel.isFull(true);
});
}, },
child: Tooltip( child: Icon(PeerTabModel.icons[PeerTabIndex.ab.index]),
message: translate('Add to address book'),
child: Icon(model.icons[PeerTabIndex.ab.index])),
).marginOnly(left: isMobile ? 11 : 6), ).marginOnly(left: isMobile ? 11 : 6),
); );
} }
@@ -481,21 +473,20 @@ class _PeerTabPageState extends State<PeerTabPage>
return Offstage( return Offstage(
offstage: !gFFI.userModel.isLogin || offstage: !gFFI.userModel.isLogin ||
model.currentTab != PeerTabIndex.ab.index || model.currentTab != PeerTabIndex.ab.index ||
gFFI.abModel.tags.isEmpty, gFFI.abModel.currentAbTags.isEmpty,
child: _hoverAction( child: _hoverAction(
context: context, context: context,
toolTip: translate('Edit Tag'),
onTap: () { onTap: () {
editAbTagDialog(List.empty(), (selectedTags) async { editAbTagDialog(List.empty(), (selectedTags) async {
final peers = model.selectedPeers; final peers = model.selectedPeers;
gFFI.abModel.changeTagForPeers( await gFFI.abModel.changeTagForPeers(
peers.map((p) => p.id).toList(), selectedTags); peers.map((p) => p.id).toList(), selectedTags);
gFFI.abModel.pushAb();
model.setMultiSelectionMode(false); model.setMultiSelectionMode(false);
showToast(translate('Successful')); showToast(translate('Successful'));
}); });
}, },
child: Tooltip( child: Icon(Icons.tag))
message: translate('Edit Tag'), child: Icon(Icons.tag)))
.marginOnly(left: isMobile ? 11 : 6), .marginOnly(left: isMobile ? 11 : 6),
); );
} }
@@ -514,11 +505,11 @@ class _PeerTabPageState extends State<PeerTabPage>
model.selectedPeers.length >= model.currentTabCachedPeers.length, model.selectedPeers.length >= model.currentTabCachedPeers.length,
child: _hoverAction( child: _hoverAction(
context: context, context: context,
toolTip: translate('Select All'),
onTap: () { onTap: () {
model.selectAll(); model.selectAll();
}, },
child: Tooltip( child: Icon(Icons.select_all),
message: translate('Select All'), child: Icon(Icons.select_all)),
).marginOnly(left: 6), ).marginOnly(left: 6),
); );
} }
@@ -527,24 +518,23 @@ class _PeerTabPageState extends State<PeerTabPage>
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
return _hoverAction( return _hoverAction(
context: context, context: context,
toolTip: translate('Close'),
onTap: () { onTap: () {
model.setMultiSelectionMode(false); model.setMultiSelectionMode(false);
}, },
child: child: Icon(Icons.clear))
Tooltip(message: translate('Close'), child: Icon(Icons.clear)))
.marginOnly(left: 6); .marginOnly(left: 6);
} }
Widget _toggleTags() { Widget _toggleTags() {
return _hoverAction( return _hoverAction(
context: context, context: context,
toolTip: translate('Toggle tags'),
hoverableWhenfalse: hideAbTagsPanel, hoverableWhenfalse: hideAbTagsPanel,
child: Tooltip( child: Icon(
message: translate('Toggle Tags'), Icons.tag_rounded,
child: Icon( size: 18,
Icons.tag_rounded, ),
size: 18,
)),
onTap: () async { onTap: () async {
await bind.mainSetLocalOption( await bind.mainSetLocalOption(
key: "hideAbTagsPanel", value: hideAbTagsPanel.value ? "" : "Y"); key: "hideAbTagsPanel", value: hideAbTagsPanel.value ? "" : "Y");
@@ -556,7 +546,8 @@ class _PeerTabPageState extends State<PeerTabPage>
final model = Provider.of<PeerTabModel>(context); final model = Provider.of<PeerTabModel>(context);
return [ return [
const PeerSearchBar().marginOnly(right: isMobile ? 0 : 13), const PeerSearchBar().marginOnly(right: isMobile ? 0 : 13),
_createRefresh(index: PeerTabIndex.ab, loading: gFFI.abModel.abLoading), _createRefresh(
index: PeerTabIndex.ab, loading: gFFI.abModel.currentAbLoading),
_createRefresh( _createRefresh(
index: PeerTabIndex.group, loading: gFFI.groupModel.groupLoading), index: PeerTabIndex.group, loading: gFFI.groupModel.groupLoading),
Offstage( Offstage(
@@ -580,7 +571,7 @@ class _PeerTabPageState extends State<PeerTabPage>
final screenWidth = MediaQuery.of(context).size.width; final screenWidth = MediaQuery.of(context).size.width;
final leftIconSize = Theme.of(context).iconTheme.size ?? 24; final leftIconSize = Theme.of(context).iconTheme.size ?? 24;
final leftActionsSize = final leftActionsSize =
(leftIconSize + (4 + 4) * 2) * model.visibleIndexs.length; (leftIconSize + (4 + 4) * 2) * model.visibleEnabledOrderedIndexs.length;
final availableWidth = screenWidth - 10 * 2 - leftActionsSize - 2 * 2; final availableWidth = screenWidth - 10 * 2 - leftActionsSize - 2 * 2;
final searchWidth = 120; final searchWidth = 120;
final otherActionWidth = 18 + 10; final otherActionWidth = 18 + 10;
@@ -593,14 +584,13 @@ class _PeerTabPageState extends State<PeerTabPage>
(BuildContext context, Future<void> Function() showMenu) { (BuildContext context, Future<void> Function() showMenu) {
return _hoverAction( return _hoverAction(
context: context, context: context,
child: Tooltip( toolTip: translate('More'),
message: translate('More'), child: SvgPicture.asset(
child: SvgPicture.asset( "assets/chevron_up_chevron_down.svg",
"assets/chevron_up_chevron_down.svg", width: 18,
width: 18, height: 18,
height: 18, colorFilter: svgColor(textColor),
colorFilter: svgColor(textColor), ),
)),
onTap: showMenu, onTap: showMenu,
); );
}, },
@@ -624,7 +614,8 @@ class _PeerTabPageState extends State<PeerTabPage>
List<Widget> actions = [ List<Widget> actions = [
const PeerSearchBar(), const PeerSearchBar(),
if (model.currentTab == PeerTabIndex.ab.index) if (model.currentTab == PeerTabIndex.ab.index)
_createRefresh(index: PeerTabIndex.ab, loading: gFFI.abModel.abLoading), _createRefresh(
index: PeerTabIndex.ab, loading: gFFI.abModel.currentAbLoading),
if (model.currentTab == PeerTabIndex.group.index) if (model.currentTab == PeerTabIndex.group.index)
_createRefresh( _createRefresh(
index: PeerTabIndex.group, loading: gFFI.groupModel.groupLoading), index: PeerTabIndex.group, loading: gFFI.groupModel.groupLoading),
@@ -674,18 +665,17 @@ class _PeerSearchBarState extends State<PeerSearchBar> {
? _buildSearchBar() ? _buildSearchBar()
: _hoverAction( : _hoverAction(
context: context, context: context,
toolTip: translate('Search'),
padding: const EdgeInsets.only(right: 2), padding: const EdgeInsets.only(right: 2),
onTap: () { onTap: () {
setState(() { setState(() {
drawer = true; drawer = true;
}); });
}, },
child: Tooltip( child: Icon(
message: translate('Search'), Icons.search_rounded,
child: Icon( color: Theme.of(context).hintColor,
Icons.search_rounded, ));
color: Theme.of(context).hintColor,
)));
} }
Widget _buildSearchBar() { Widget _buildSearchBar() {
@@ -826,16 +816,15 @@ class _PeerViewDropdownState extends State<PeerViewDropdown> {
var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0); var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0);
return _hoverAction( return _hoverAction(
context: context, context: context,
child: Tooltip( toolTip: translate('Change view'),
message: translate('Change view'), child: Icon(
child: Icon( peerCardUiType.value == PeerUiType.grid
peerCardUiType.value == PeerUiType.grid ? Icons.grid_view_rounded
? Icons.grid_view_rounded : peerCardUiType.value == PeerUiType.tile
: peerCardUiType.value == PeerUiType.tile ? Icons.view_list_rounded
? Icons.view_list_rounded : Icons.view_agenda_rounded,
: Icons.view_agenda_rounded, size: 18,
size: 18, ),
)),
onTapDown: (details) { onTapDown: (details) {
final x = details.globalPosition.dx; final x = details.globalPosition.dx;
final y = details.globalPosition.dy; final y = details.globalPosition.dy;
@@ -905,12 +894,11 @@ class _PeerSortDropdownState extends State<PeerSortDropdown> {
var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0); var menuPos = RelativeRect.fromLTRB(0, 0, 0, 0);
return _hoverAction( return _hoverAction(
context: context, context: context,
child: Tooltip( toolTip: translate('Sort by'),
message: translate('Sort by'), child: Icon(
child: Icon( Icons.sort_rounded,
Icons.sort_rounded, size: 18,
size: 18, ),
)),
onTapDown: (details) { onTapDown: (details) {
final x = details.globalPosition.dx; final x = details.globalPosition.dx;
final y = details.globalPosition.dy; final y = details.globalPosition.dy;
@@ -992,6 +980,7 @@ Widget _hoverAction(
{required BuildContext context, {required BuildContext context,
required Widget child, required Widget child,
required Function() onTap, required Function() onTap,
required String toolTip,
GestureTapDownCallback? onTapDown, GestureTapDownCallback? onTapDown,
RxBool? hoverableWhenfalse, RxBool? hoverableWhenfalse,
EdgeInsetsGeometry padding = const EdgeInsets.all(4.0)}) { EdgeInsetsGeometry padding = const EdgeInsets.all(4.0)}) {
@@ -1000,16 +989,19 @@ Widget _hoverAction(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
); );
return Obx( return Tooltip(
() => Container( message: toolTip,
margin: EdgeInsets.symmetric(horizontal: 1), child: Obx(
decoration: () => Container(
(hover.value || hoverableWhenfalse?.value == false) ? deco : null, margin: EdgeInsets.symmetric(horizontal: 1),
child: InkWell( decoration:
onHover: (value) => hover.value = value, (hover.value || hoverableWhenfalse?.value == false) ? deco : null,
onTap: onTap, child: InkWell(
onTapDown: onTapDown, onHover: (value) => hover.value = value,
child: Container(padding: padding, child: child))), onTap: onTap,
onTapDown: onTapDown,
child: Container(padding: padding, child: child))),
),
); );
} }

View File

@@ -78,7 +78,7 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
LoadEvent.lan: 'empty_lan_tip', LoadEvent.lan: 'empty_lan_tip',
LoadEvent.addressBook: 'empty_address_book_tip', LoadEvent.addressBook: 'empty_address_book_tip',
}); });
final space = isDesktop ? 12.0 : 8.0; final space = (isDesktop || isWebDesktop) ? 12.0 : 8.0;
final _curPeers = <String>{}; final _curPeers = <String>{};
var _lastChangeTime = DateTime.now(); var _lastChangeTime = DateTime.now();
var _lastQueryPeers = <String>{}; var _lastQueryPeers = <String>{};
@@ -86,17 +86,6 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
var _queryCount = 0; var _queryCount = 0;
var _exit = false; var _exit = false;
late final mobileWidth = () {
const minWidth = 320.0;
final windowWidth = MediaQuery.of(context).size.width;
var width = windowWidth - 2 * space;
if (windowWidth > minWidth + 2 * space) {
final n = (windowWidth / (minWidth + 2 * space)).floor();
width = windowWidth / n - 2 * space;
}
return width;
}();
final _scrollController = ScrollController(); final _scrollController = ScrollController();
_PeersViewState() { _PeersViewState() {
@@ -189,54 +178,60 @@ class _PeersViewState extends State<_PeersView> with WindowListener {
onVisibilityChanged: onVisibilityChanged, onVisibilityChanged: onVisibilityChanged,
child: widget.peerCardBuilder(peer), child: widget.peerCardBuilder(peer),
); );
final windowWidth = MediaQuery.of(context).size.width;
// `Provider.of<PeerTabModel>(context)` will causes infinete loop. // `Provider.of<PeerTabModel>(context)` will causes infinete loop.
// Because `gFFI.peerTabModel.setCurrentTabCachedPeers(peers)` will trigger `notifyListeners()`. // Because `gFFI.peerTabModel.setCurrentTabCachedPeers(peers)` will trigger `notifyListeners()`.
// //
// No need to listen the currentTab change event. // No need to listen the currentTab change event.
// Because the currentTab change event will trigger the peers change event, // Because the currentTab change event will trigger the peers change event,
// and the peers change event will trigger _buildPeersView(). // and the peers change event will trigger _buildPeersView().
final currentTab = Provider.of<PeerTabModel>(context, listen: false).currentTab; return (isDesktop || isWebDesktop)
final hideAbTagsPanel = bind.mainGetLocalOption(key: "hideAbTagsPanel").isNotEmpty; ? Obx(() => peerCardUiType.value == PeerUiType.list
return isDesktop ? Container(height: 45, child: visibilityChild)
? Obx( : peerCardUiType.value == PeerUiType.grid
() => SizedBox( ? SizedBox(
width: peerCardUiType.value != PeerUiType.list width: 220, height: 140, child: visibilityChild)
? 220 : SizedBox(
: currentTab == PeerTabIndex.group.index || (currentTab == PeerTabIndex.ab.index && !hideAbTagsPanel) width: 220, height: 42, child: visibilityChild))
? windowWidth - 390 : : Container(child: visibilityChild);
windowWidth - 227,
height:
peerCardUiType.value == PeerUiType.grid ? 140 : peerCardUiType.value != PeerUiType.list ? 42 : 45,
child: visibilityChild,
),
)
: SizedBox(width: mobileWidth, child: visibilityChild);
} }
final Widget child; final Widget child;
if (isMobile) { if (isMobile) {
child = DynamicGridView.builder( child = ListView.builder(
gridDelegate: SliverGridDelegateWithWrapping(
mainAxisSpacing: space / 2, crossAxisSpacing: space),
itemCount: peers.length, itemCount: peers.length,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return buildOnePeer(peers[index]); return buildOnePeer(peers[index]).marginOnly(
top: index == 0 ? 0 : space / 2, bottom: space / 2);
}, },
); );
} else { } else {
child = DesktopScrollWrapper( child = Obx(() => peerCardUiType.value == PeerUiType.list
scrollController: _scrollController, ? DesktopScrollWrapper(
child: DynamicGridView.builder( scrollController: _scrollController,
controller: _scrollController, child: ListView.builder(
physics: DraggableNeverScrollableScrollPhysics(), controller: _scrollController,
gridDelegate: SliverGridDelegateWithWrapping( physics: DraggableNeverScrollableScrollPhysics(),
mainAxisSpacing: space / 2, crossAxisSpacing: space), itemCount: peers.length,
itemCount: peers.length, itemBuilder: (BuildContext context, int index) {
itemBuilder: (BuildContext context, int index) { return buildOnePeer(peers[index]).marginOnly(
return buildOnePeer(peers[index]); right: space,
}), top: index == 0 ? 0 : space / 2,
); bottom: space / 2);
}),
)
: DesktopScrollWrapper(
scrollController: _scrollController,
child: DynamicGridView.builder(
controller: _scrollController,
physics: DraggableNeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithWrapping(
mainAxisSpacing: space / 2,
crossAxisSpacing: space),
itemCount: peers.length,
itemBuilder: (BuildContext context, int index) {
return buildOnePeer(peers[index]);
}),
));
} }
if (updateEvent == UpdateEvent.load) { if (updateEvent == UpdateEvent.load) {
@@ -354,7 +349,7 @@ abstract class BasePeersView extends StatelessWidget {
final String loadEvent; final String loadEvent;
final PeerFilter? peerFilter; final PeerFilter? peerFilter;
final PeerCardBuilder peerCardBuilder; final PeerCardBuilder peerCardBuilder;
final RxList<Peer>? initPeers; final GetInitPeers? getInitPeers;
const BasePeersView({ const BasePeersView({
Key? key, Key? key,
@@ -362,13 +357,14 @@ abstract class BasePeersView extends StatelessWidget {
required this.loadEvent, required this.loadEvent,
this.peerFilter, this.peerFilter,
required this.peerCardBuilder, required this.peerCardBuilder,
required this.initPeers, required this.getInitPeers,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _PeersView( return _PeersView(
peers: Peers(name: name, loadEvent: loadEvent, initPeers: initPeers), peers:
Peers(name: name, loadEvent: loadEvent, getInitPeers: getInitPeers),
peerFilter: peerFilter, peerFilter: peerFilter,
peerCardBuilder: peerCardBuilder); peerCardBuilder: peerCardBuilder);
} }
@@ -385,7 +381,7 @@ class RecentPeersView extends BasePeersView {
peer: peer, peer: peer,
menuPadding: menuPadding, menuPadding: menuPadding,
), ),
initPeers: null, getInitPeers: null,
); );
@override @override
@@ -407,7 +403,7 @@ class FavoritePeersView extends BasePeersView {
peer: peer, peer: peer,
menuPadding: menuPadding, menuPadding: menuPadding,
), ),
initPeers: null, getInitPeers: null,
); );
@override @override
@@ -429,7 +425,7 @@ class DiscoveredPeersView extends BasePeersView {
peer: peer, peer: peer,
menuPadding: menuPadding, menuPadding: menuPadding,
), ),
initPeers: null, getInitPeers: null,
); );
@override @override
@@ -445,7 +441,7 @@ class AddressBookPeersView extends BasePeersView {
{Key? key, {Key? key,
EdgeInsets? menuPadding, EdgeInsets? menuPadding,
ScrollController? scrollController, ScrollController? scrollController,
required RxList<Peer> initPeers}) required GetInitPeers getInitPeers})
: super( : super(
key: key, key: key,
name: 'address book peer', name: 'address book peer',
@@ -456,7 +452,7 @@ class AddressBookPeersView extends BasePeersView {
peer: peer, peer: peer,
menuPadding: menuPadding, menuPadding: menuPadding,
), ),
initPeers: initPeers, getInitPeers: getInitPeers,
); );
static bool _hitTag(List<dynamic> selectedTags, List<dynamic> idents) { static bool _hitTag(List<dynamic> selectedTags, List<dynamic> idents) {
@@ -486,7 +482,7 @@ class MyGroupPeerView extends BasePeersView {
{Key? key, {Key? key,
EdgeInsets? menuPadding, EdgeInsets? menuPadding,
ScrollController? scrollController, ScrollController? scrollController,
required RxList<Peer> initPeers}) required GetInitPeers getInitPeers})
: super( : super(
key: key, key: key,
name: 'group peer', name: 'group peer',
@@ -496,7 +492,7 @@ class MyGroupPeerView extends BasePeersView {
peer: peer, peer: peer,
menuPadding: menuPadding, menuPadding: menuPadding,
), ),
initPeers: initPeers, getInitPeers: getInitPeers,
); );
static bool filter(Peer peer) { static bool filter(Peer peer) {

View File

@@ -77,7 +77,7 @@ class _RawTouchGestureDetectorRegionState
FFI get ffi => widget.ffi; FFI get ffi => widget.ffi;
FfiModel get ffiModel => widget.ffiModel; FfiModel get ffiModel => widget.ffiModel;
InputModel get inputModel => widget.inputModel; InputModel get inputModel => widget.inputModel;
bool get handleTouch => isDesktop || ffiModel.touchMode; bool get handleTouch => (isDesktop || isWebDesktop) || ffiModel.touchMode;
SessionID get sessionId => ffi.sessionId; SessionID get sessionId => ffi.sessionId;
@override @override
@@ -183,7 +183,7 @@ class _RawTouchGestureDetectorRegionState
if (lastDeviceKind != PointerDeviceKind.touch) { if (lastDeviceKind != PointerDeviceKind.touch) {
return; return;
} }
if (isDesktop || !ffiModel.touchMode) { if ((isDesktop || isWebDesktop) || !ffiModel.touchMode) {
inputModel.tap(MouseButtons.right); inputModel.tap(MouseButtons.right);
} }
} }
@@ -203,7 +203,7 @@ class _RawTouchGestureDetectorRegionState
return; return;
} }
if (!handleTouch) { if (!handleTouch) {
ffi.cursorModel.updatePan(d.delta.dx, d.delta.dy, handleTouch); ffi.cursorModel.updatePan(d.delta, d.localPosition, handleTouch);
} }
} }
@@ -222,6 +222,9 @@ class _RawTouchGestureDetectorRegionState
return; return;
} }
if (handleTouch) { if (handleTouch) {
if (isDesktop) {
ffi.cursorModel.trySetRemoteWindowCoords();
}
inputModel.sendMouse('down', MouseButtons.left); inputModel.sendMouse('down', MouseButtons.left);
ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy); ffi.cursorModel.move(d.localPosition.dx, d.localPosition.dy);
} else { } else {
@@ -241,13 +244,16 @@ class _RawTouchGestureDetectorRegionState
if (lastDeviceKind != PointerDeviceKind.touch) { if (lastDeviceKind != PointerDeviceKind.touch) {
return; return;
} }
ffi.cursorModel.updatePan(d.delta.dx, d.delta.dy, handleTouch); ffi.cursorModel.updatePan(d.delta, d.localPosition, handleTouch);
} }
onOneFingerPanEnd(DragEndDetails d) { onOneFingerPanEnd(DragEndDetails d) {
if (lastDeviceKind != PointerDeviceKind.touch) { if (lastDeviceKind != PointerDeviceKind.touch) {
return; return;
} }
if (isDesktop) {
ffi.cursorModel.clearRemoteWindowCoords();
}
inputModel.sendMouse('up', MouseButtons.left); inputModel.sendMouse('up', MouseButtons.left);
} }
@@ -262,7 +268,7 @@ class _RawTouchGestureDetectorRegionState
if (lastDeviceKind != PointerDeviceKind.touch) { if (lastDeviceKind != PointerDeviceKind.touch) {
return; return;
} }
if (isDesktop) { if ((isDesktop || isWebDesktop)) {
final scale = ((d.scale - _scale) * 1000).toInt(); final scale = ((d.scale - _scale) * 1000).toInt();
_scale = d.scale; _scale = d.scale;
@@ -286,7 +292,7 @@ class _RawTouchGestureDetectorRegionState
if (lastDeviceKind != PointerDeviceKind.touch) { if (lastDeviceKind != PointerDeviceKind.touch) {
return; return;
} }
if (isDesktop) { if ((isDesktop || isWebDesktop)) {
bind.sessionSendPointer( bind.sessionSendPointer(
sessionId: sessionId, sessionId: sessionId,
msg: json.encode( msg: json.encode(
@@ -409,7 +415,9 @@ class RawPointerMouseRegion extends StatelessWidget {
onPointerPanZoomUpdate: inputModel.onPointerPanZoomUpdate, onPointerPanZoomUpdate: inputModel.onPointerPanZoomUpdate,
onPointerPanZoomEnd: inputModel.onPointerPanZoomEnd, onPointerPanZoomEnd: inputModel.onPointerPanZoomEnd,
child: MouseRegion( child: MouseRegion(
cursor: cursor ?? MouseCursor.defer, cursor: inputModel.isViewOnly
? MouseCursor.defer
: (cursor ?? MouseCursor.defer),
onEnter: onEnter, onEnter: onEnter,
onExit: onExit, onExit: onExit,
child: child, child: child,

View File

@@ -209,10 +209,12 @@ List<Widget> ServerConfigImportExportWidgets(
List<(String, String)> otherDefaultSettings() { List<(String, String)> otherDefaultSettings() {
List<(String, String)> v = [ List<(String, String)> v = [
('View Mode', 'view_only'), ('View Mode', 'view_only'),
if (isDesktop) ('show_monitors_tip', kKeyShowMonitorsToolbar), if ((isDesktop || isWebDesktop)) ('show_monitors_tip', kKeyShowMonitorsToolbar),
if (isDesktop) ('Collapse toolbar', 'collapse_toolbar'), if ((isDesktop || isWebDesktop)) ('Collapse toolbar', 'collapse_toolbar'),
('Show remote cursor', 'show_remote_cursor'), ('Show remote cursor', 'show_remote_cursor'),
if (isDesktop) ('Zoom cursor', 'zoom-cursor'), ('Follow remote cursor', 'follow_remote_cursor'),
('Follow remote window focus', 'follow_remote_window'),
if ((isDesktop || isWebDesktop)) ('Zoom cursor', 'zoom-cursor'),
('Show quality monitor', 'show_quality_monitor'), ('Show quality monitor', 'show_quality_monitor'),
('Mute', 'disable_audio'), ('Mute', 'disable_audio'),
if (isDesktop) ('Enable file copy and paste', 'enable_file_transfer'), if (isDesktop) ('Enable file copy and paste', 'enable_file_transfer'),
@@ -221,7 +223,7 @@ List<(String, String)> otherDefaultSettings() {
('Privacy mode', 'privacy_mode'), ('Privacy mode', 'privacy_mode'),
if (isMobile) ('Touch mode', 'touch-mode'), if (isMobile) ('Touch mode', 'touch-mode'),
('True color (4:4:4)', 'i444'), ('True color (4:4:4)', 'i444'),
('Reverse mouse wheel', 'reverse_mouse_wheel'), ('Reverse mouse wheel', kKeyReverseMouseWheel),
('swap-left-right-mouse', 'swap-left-right-mouse'), ('swap-left-right-mouse', 'swap-left-right-mouse'),
if (isDesktop && useTextureRender) if (isDesktop && useTextureRender)
( (

View File

@@ -1,5 +1,4 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
@@ -95,7 +94,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
Text(translate(pi.isHeadless ? 'OS Account' : 'OS Password')), Text(translate(pi.isHeadless ? 'OS Account' : 'OS Password')),
]), ]),
trailingIcon: Transform.scale( trailingIcon: Transform.scale(
scale: isDesktop ? 0.8 : 1, scale: (isDesktop || isWebDesktop) ? 0.8 : 1,
child: IconButton( child: IconButton(
onPressed: () { onPressed: () {
if (isMobile && Navigator.canPop(context)) { if (isMobile && Navigator.canPop(context)) {
@@ -161,7 +160,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
); );
} }
// divider // divider
if (isDesktop) { if (isDesktop || isWebDesktop) {
v.add(TTextMenu(child: Offstage(), onPressed: () {}, divider: true)); v.add(TTextMenu(child: Offstage(), onPressed: () {}, divider: true));
} }
// ctrlAltDel // ctrlAltDel
@@ -230,7 +229,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
)); ));
} }
// record // record
if (!isDesktop && if (!(isDesktop || isWeb) &&
(ffi.recordingModel.start || (perms["recording"] != false))) { (ffi.recordingModel.start || (perms["recording"] != false))) {
v.add(TTextMenu( v.add(TTextMenu(
child: Row( child: Row(
@@ -251,7 +250,7 @@ List<TTextMenu> toolbarControls(BuildContext context, String id, FFI ffi) {
onPressed: () => ffi.recordingModel.toggle())); onPressed: () => ffi.recordingModel.toggle()));
} }
// fingerprint // fingerprint
if (!isDesktop) { if (!(isDesktop || isWebDesktop)) {
v.add(TTextMenu( v.add(TTextMenu(
child: Text(translate('Copy Fingerprint')), child: Text(translate('Copy Fingerprint')),
onPressed: () => onCopyFingerprint(FingerprintState.find(id).value), onPressed: () => onCopyFingerprint(FingerprintState.find(id).value),
@@ -356,14 +355,18 @@ Future<List<TRadioMenu<String>>> toolbarCodec(
TRadioMenu<String> radio(String label, String value, bool enabled) { TRadioMenu<String> radio(String label, String value, bool enabled) {
return TRadioMenu<String>( return TRadioMenu<String>(
child: Text(translate(label)), child: Text(label),
value: value, value: value,
groupValue: groupValue, groupValue: groupValue,
onChanged: enabled ? onChanged : null); onChanged: enabled ? onChanged : null);
} }
var autoLabel = translate('Auto');
if (groupValue == 'auto') {
autoLabel = '$autoLabel (${ffi.qualityMonitorModel.data.codecFormat})';
}
return [ return [
radio('Auto', 'auto', true), radio(autoLabel, 'auto', true),
if (codecs[0]) radio('VP8', 'vp8', codecs[0]), if (codecs[0]) radio('VP8', 'vp8', codecs[0]),
radio('VP9', 'vp9', true), radio('VP9', 'vp9', true),
if (codecs[1]) radio('AV1', 'av1', codecs[1]), if (codecs[1]) radio('AV1', 'av1', codecs[1]),
@@ -372,7 +375,7 @@ Future<List<TRadioMenu<String>>> toolbarCodec(
]; ];
} }
Future<List<TToggleMenu>> toolbarDisplayToggle( Future<List<TToggleMenu>> toolbarCursor(
BuildContext context, String id, FFI ffi) async { BuildContext context, String id, FFI ffi) async {
List<TToggleMenu> v = []; List<TToggleMenu> v = [];
final ffiModel = ffi.ffiModel; final ffiModel = ffi.ffiModel;
@@ -385,12 +388,17 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
!ffi.canvasModel.cursorEmbedded && !ffi.canvasModel.cursorEmbedded &&
!pi.isWayland) { !pi.isWayland) {
final state = ShowRemoteCursorState.find(id); final state = ShowRemoteCursorState.find(id);
final lockState = ShowRemoteCursorLockState.find(id);
final enabled = !ffiModel.viewOnly; final enabled = !ffiModel.viewOnly;
final option = 'show-remote-cursor'; final option = 'show-remote-cursor';
if (pi.currentDisplay == kAllDisplayValue ||
bind.sessionIsMultiUiSession(sessionId: sessionId)) {
lockState.value = false;
}
v.add(TToggleMenu( v.add(TToggleMenu(
child: Text(translate('Show remote cursor')), child: Text(translate('Show remote cursor')),
value: state.value, value: state.value,
onChanged: enabled onChanged: enabled && !lockState.value
? (value) async { ? (value) async {
if (value == null) return; if (value == null) return;
await bind.sessionToggleOption( await bind.sessionToggleOption(
@@ -400,6 +408,67 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
} }
: null)); : null));
} }
// follow remote cursor
if (pi.platform != kPeerPlatformAndroid &&
!ffi.canvasModel.cursorEmbedded &&
!pi.isWayland &&
versionCmp(pi.version, "1.2.4") >= 0 &&
pi.displays.length > 1 &&
pi.currentDisplay != kAllDisplayValue &&
!bind.sessionIsMultiUiSession(sessionId: sessionId)) {
final option = 'follow-remote-cursor';
final value =
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
final showCursorOption = 'show-remote-cursor';
final showCursorState = ShowRemoteCursorState.find(id);
final showCursorLockState = ShowRemoteCursorLockState.find(id);
final showCursorEnabled = bind.sessionGetToggleOptionSync(
sessionId: sessionId, arg: showCursorOption);
showCursorLockState.value = value;
if (value && !showCursorEnabled) {
await bind.sessionToggleOption(
sessionId: sessionId, value: showCursorOption);
showCursorState.value = bind.sessionGetToggleOptionSync(
sessionId: sessionId, arg: showCursorOption);
}
v.add(TToggleMenu(
child: Text(translate('Follow remote cursor')),
value: value,
onChanged: (value) async {
if (value == null) return;
await bind.sessionToggleOption(sessionId: sessionId, value: option);
value = bind.sessionGetToggleOptionSync(
sessionId: sessionId, arg: option);
showCursorLockState.value = value;
if (!showCursorEnabled) {
await bind.sessionToggleOption(
sessionId: sessionId, value: showCursorOption);
showCursorState.value = bind.sessionGetToggleOptionSync(
sessionId: sessionId, arg: showCursorOption);
}
}));
}
// follow remote window focus
if (pi.platform != kPeerPlatformAndroid &&
!ffi.canvasModel.cursorEmbedded &&
!pi.isWayland &&
versionCmp(pi.version, "1.2.4") >= 0 &&
pi.displays.length > 1 &&
pi.currentDisplay != kAllDisplayValue &&
!bind.sessionIsMultiUiSession(sessionId: sessionId)) {
final option = 'follow-remote-window';
final value =
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
v.add(TToggleMenu(
child: Text(translate('Follow remote window focus')),
value: value,
onChanged: (value) async {
if (value == null) return;
await bind.sessionToggleOption(sessionId: sessionId, value: option);
value = bind.sessionGetToggleOptionSync(
sessionId: sessionId, arg: option);
}));
}
// zoom cursor // zoom cursor
final viewStyle = await bind.sessionGetViewStyle(sessionId: sessionId) ?? ''; final viewStyle = await bind.sessionGetViewStyle(sessionId: sessionId) ?? '';
if (!isMobile && if (!isMobile &&
@@ -418,6 +487,17 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
}, },
)); ));
} }
return v;
}
Future<List<TToggleMenu>> toolbarDisplayToggle(
BuildContext context, String id, FFI ffi) async {
List<TToggleMenu> v = [];
final ffiModel = ffi.ffiModel;
final pi = ffiModel.pi;
final perms = ffiModel.permissions;
final sessionId = ffi.sessionId;
// show quality monitor // show quality monitor
final option = 'show-quality-monitor'; final option = 'show-quality-monitor';
v.add(TToggleMenu( v.add(TToggleMenu(
@@ -442,10 +522,17 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
child: Text(translate('Mute')))); child: Text(translate('Mute'))));
} }
// file copy and paste // file copy and paste
// If the version is less than 1.2.4, file copy and paste is supported on Windows only.
final isSupportIfPeer_1_2_3 = versionCmp(pi.version, '1.2.4') < 0 &&
isWindows &&
pi.platform == kPeerPlatformWindows;
// If the version is 1.2.4 or later, file copy and paste is supported when kPlatformAdditionsHasFileClipboard is set.
final isSupportIfPeer_1_2_4 = versionCmp(pi.version, '1.2.4') >= 0 &&
bind.mainHasFileClipboard() &&
pi.platformAdditions.containsKey(kPlatformAdditionsHasFileClipboard);
if (ffiModel.keyboard && if (ffiModel.keyboard &&
perms['file'] != false && perms['file'] != false &&
bind.mainHasFileClipboard() && (isSupportIfPeer_1_2_3 || isSupportIfPeer_1_2_4)) {
pi.platformAdditions.containsKey(kPlatformAdditionsHasFileClipboard)) {
final enabled = !ffiModel.viewOnly; final enabled = !ffiModel.viewOnly;
final option = 'enable-file-transfer'; final option = 'enable-file-transfer';
final value = final value =
@@ -512,8 +599,8 @@ Future<List<TToggleMenu>> toolbarDisplayToggle(
child: Text(translate('Show displays as individual windows')))); child: Text(translate('Show displays as individual windows'))));
} }
final screenList = await getScreenRectList(); final isMultiScreens = !isWeb && (await getScreenRectList()).length > 1;
if (useTextureRender && pi.isSupportMultiDisplay && screenList.length > 1) { if (useTextureRender && pi.isSupportMultiDisplay && isMultiScreens) {
final value = bind.sessionGetUseAllMyDisplaysForTheRemoteSession( final value = bind.sessionGetUseAllMyDisplaysForTheRemoteSession(
sessionId: ffi.sessionId) == sessionId: ffi.sessionId) ==
'Y'; 'Y';
@@ -633,8 +720,8 @@ List<TToggleMenu> toolbarKeyboardToggles(FFI ffi) {
// swap key // swap key
if (ffiModel.keyboard && if (ffiModel.keyboard &&
((Platform.isMacOS && pi.platform != kPeerPlatformMacOS) || ((isMacOS && pi.platform != kPeerPlatformMacOS) ||
(!Platform.isMacOS && pi.platform == kPeerPlatformMacOS))) { (!isMacOS && pi.platform == kPeerPlatformMacOS))) {
final option = 'allow_swap_key'; final option = 'allow_swap_key';
final value = final value =
bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option); bind.sessionGetToggleOptionSync(sessionId: sessionId, arg: option);
@@ -655,7 +742,7 @@ List<TToggleMenu> toolbarKeyboardToggles(FFI ffi) {
var optionValue = var optionValue =
bind.sessionGetReverseMouseWheelSync(sessionId: sessionId) ?? ''; bind.sessionGetReverseMouseWheelSync(sessionId: sessionId) ?? '';
if (optionValue == '') { if (optionValue == '') {
optionValue = bind.mainGetUserDefaultOption(key: 'reverse_mouse_wheel'); optionValue = bind.mainGetUserDefaultOption(key: kKeyReverseMouseWheel);
} }
onChanged(bool? value) async { onChanged(bool? value) async {
if (value == null) return; if (value == null) return;

View File

@@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/models/state_model.dart';
@@ -21,9 +19,14 @@ const kKeyTranslateMode = 'translate';
const String kPlatformAdditionsIsWayland = "is_wayland"; const String kPlatformAdditionsIsWayland = "is_wayland";
const String kPlatformAdditionsHeadless = "headless"; const String kPlatformAdditionsHeadless = "headless";
const String kPlatformAdditionsIsInstalled = "is_installed"; const String kPlatformAdditionsIsInstalled = "is_installed";
const String kPlatformAdditionsVirtualDisplays = "virtual_displays"; const String kPlatformAdditionsIddImpl = "idd_impl";
const String kPlatformAdditionsRustDeskVirtualDisplays =
"rustdesk_virtual_displays";
const String kPlatformAdditionsAmyuniVirtualDisplays =
"amyuni_virtual_displays";
const String kPlatformAdditionsHasFileClipboard = "has_file_clipboard"; const String kPlatformAdditionsHasFileClipboard = "has_file_clipboard";
const String kPlatformAdditionsSupportedPrivacyModeImpl = "supported_privacy_mode_impl"; const String kPlatformAdditionsSupportedPrivacyModeImpl =
"supported_privacy_mode_impl";
const String kPeerPlatformWindows = "Windows"; const String kPeerPlatformWindows = "Windows";
const String kPeerPlatformLinux = "Linux"; const String kPeerPlatformLinux = "Linux";
@@ -59,6 +62,7 @@ const String kWindowEventActiveSession = "active_session";
const String kWindowEventActiveDisplaySession = "active_display_session"; const String kWindowEventActiveDisplaySession = "active_display_session";
const String kWindowEventGetRemoteList = "get_remote_list"; const String kWindowEventGetRemoteList = "get_remote_list";
const String kWindowEventGetSessionIdList = "get_session_id_list"; const String kWindowEventGetSessionIdList = "get_session_id_list";
const String kWindowEventRemoteWindowCoords = "remote_window_coords";
const String kWindowEventMoveTabToNewWindow = "move_tab_to_new_window"; const String kWindowEventMoveTabToNewWindow = "move_tab_to_new_window";
const String kWindowEventGetCachedSessionData = "get_cached_session_data"; const String kWindowEventGetCachedSessionData = "get_cached_session_data";
@@ -68,8 +72,8 @@ const String kOptionOpenNewConnInTabs = "enable-open-new-connections-in-tabs";
const String kOptionOpenInTabs = "allow-open-in-tabs"; const String kOptionOpenInTabs = "allow-open-in-tabs";
const String kOptionOpenInWindows = "allow-open-in-windows"; const String kOptionOpenInWindows = "allow-open-in-windows";
const String kOptionForceAlwaysRelay = "force-always-relay"; const String kOptionForceAlwaysRelay = "force-always-relay";
const String kOptionViewOnly = "view-only";
const String kUniLinksPrefix = "rustdesk://";
const String kUrlActionClose = "close"; const String kUrlActionClose = "close";
const String kTabLabelHomePage = "Home"; const String kTabLabelHomePage = "Home";
@@ -86,6 +90,7 @@ const String kKeyShowDisplaysAsIndividualWindows =
const String kKeyUseAllMyDisplaysForTheRemoteSession = const String kKeyUseAllMyDisplaysForTheRemoteSession =
'use_all_my_displays_for_the_remote_session'; 'use_all_my_displays_for_the_remote_session';
const String kKeyShowMonitorsToolbar = 'show_monitors_toolbar'; const String kKeyShowMonitorsToolbar = 'show_monitors_toolbar';
const String kKeyReverseMouseWheel = "reverse_mouse_wheel";
// the executable name of the portable version // the executable name of the portable version
const String kEnvPortableExecutable = "RUSTDESK_APPNAME"; const String kEnvPortableExecutable = "RUSTDESK_APPNAME";
@@ -113,20 +118,19 @@ const double kDefaultQuality = 50;
const double kMaxQuality = 100; const double kMaxQuality = 100;
const double kMaxMoreQuality = 2000; const double kMaxMoreQuality = 2000;
double kNewWindowOffset = Platform.isWindows double kNewWindowOffset = isWindows
? 56.0 ? 56.0
: Platform.isLinux : isLinux
? 50.0 ? 50.0
: Platform.isMacOS : isMacOS
? 30.0 ? 30.0
: 50.0; : 50.0;
EdgeInsets get kDragToResizeAreaPadding => EdgeInsets get kDragToResizeAreaPadding => !kUseCompatibleUiMode && isLinux
!kUseCompatibleUiMode && Platform.isLinux ? stateGlobal.fullscreen.isTrue || stateGlobal.isMaximized.value
? stateGlobal.fullscreen.isTrue || stateGlobal.isMaximized.value ? EdgeInsets.zero
? EdgeInsets.zero : EdgeInsets.all(5.0)
: EdgeInsets.all(5.0) : EdgeInsets.zero;
: EdgeInsets.zero;
// https://en.wikipedia.org/wiki/Non-breaking_space // https://en.wikipedia.org/wiki/Non-breaking_space
const int $nbsp = 0x00A0; const int $nbsp = 0x00A0;
@@ -150,9 +154,15 @@ const kDefaultScrollDuration = Duration(milliseconds: 50);
const kDefaultMouseWheelThrottleDuration = Duration(milliseconds: 50); const kDefaultMouseWheelThrottleDuration = Duration(milliseconds: 50);
const kFullScreenEdgeSize = 0.0; const kFullScreenEdgeSize = 0.0;
const kMaximizeEdgeSize = 0.0; const kMaximizeEdgeSize = 0.0;
var kWindowEdgeSize = Platform.isWindows ? 1.0 : 5.0; // Do not use kWindowEdgeSize directly. Use `windowEdgeSize` in `common.dart` instead.
const kWindowBorderWidth = 1.0; final kWindowEdgeSize = isWindows ? 1.0 : 5.0;
final kWindowBorderWidth = isLinux ? 1.0 : 0.0;
const kDesktopMenuPadding = EdgeInsets.only(left: 12.0, right: 3.0); const kDesktopMenuPadding = EdgeInsets.only(left: 12.0, right: 3.0);
const kFrameBorderRadius = 12.0;
const kFrameClipRRectBorderRadius = 12.0;
const kFrameBoxShadowBlurRadius = 32.0;
const kFrameBoxShadowOffsetFocused = 4.0;
const kFrameBoxShadowOffsetUnfocused = 2.0;
const kInvalidValueStr = 'InvalidValueStr'; const kInvalidValueStr = 'InvalidValueStr';
@@ -222,6 +232,7 @@ const kManageExternalStorage = "android.permission.MANAGE_EXTERNAL_STORAGE";
const kRequestIgnoreBatteryOptimizations = const kRequestIgnoreBatteryOptimizations =
"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"; "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
const kSystemAlertWindow = "android.permission.SYSTEM_ALERT_WINDOW"; const kSystemAlertWindow = "android.permission.SYSTEM_ALERT_WINDOW";
const kAndroid13Notification = "android.permission.POST_NOTIFICATIONS";
/// Android channel invoke type key /// Android channel invoke type key
class AndroidChannel { class AndroidChannel {

View File

@@ -2,7 +2,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -20,6 +19,173 @@ import '../../common/widgets/autocomplete.dart';
import '../../models/platform_model.dart'; import '../../models/platform_model.dart';
import '../widgets/button.dart'; import '../widgets/button.dart';
class OnlineStatusWidget extends StatefulWidget {
const OnlineStatusWidget({Key? key, this.onSvcStatusChanged})
: super(key: key);
final VoidCallback? onSvcStatusChanged;
@override
State<OnlineStatusWidget> createState() => _OnlineStatusWidgetState();
}
/// State for the connection page.
class _OnlineStatusWidgetState extends State<OnlineStatusWidget> {
final _svcStopped = Get.find<RxBool>(tag: 'stop-service');
final _svcIsUsingPublicServer = true.obs;
Timer? _updateTimer;
double get em => 14.0;
double? get height => bind.isIncomingOnly() ? null : em * 3;
void onUsePublicServerGuide() {
const url = "https://rustdesk.com/pricing.html";
canLaunchUrlString(url).then((can) {
if (can) {
launchUrlString(url);
}
});
}
@override
void initState() {
super.initState();
_updateTimer = periodic_immediate(Duration(seconds: 1), () async {
updateStatus();
});
}
@override
void dispose() {
_updateTimer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
final isIncomingOnly = bind.isIncomingOnly();
startServiceWidget() => Offstage(
offstage: !_svcStopped.value,
child: InkWell(
onTap: () async {
await start_service(true);
},
child: Text(translate("Start service"),
style: TextStyle(
decoration: TextDecoration.underline, fontSize: em)))
.marginOnly(left: em),
);
setupServerWidget() => Flexible(
child: Offstage(
offstage: !(!_svcStopped.value &&
stateGlobal.svcStatus.value == SvcStatus.ready &&
_svcIsUsingPublicServer.value),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(', ', style: TextStyle(fontSize: em)),
Flexible(
child: InkWell(
onTap: onUsePublicServerGuide,
child: Row(
children: [
Flexible(
child: Text(
translate('setup_server_tip'),
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: em),
),
),
],
),
),
)
],
),
),
);
basicWidget() => Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 8,
width: 8,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: _svcStopped.value ||
stateGlobal.svcStatus.value == SvcStatus.connecting
? kColorWarn
: (stateGlobal.svcStatus.value == SvcStatus.ready
? Color.fromARGB(255, 50, 190, 166)
: Color.fromARGB(255, 224, 79, 95)),
),
).marginSymmetric(horizontal: em),
Container(
width: isIncomingOnly ? 226 : null,
child: _buildConnStatusMsg(),
),
// stop
if (!isIncomingOnly) startServiceWidget(),
// ready && public
// No need to show the guide if is custom client.
if (!isIncomingOnly) setupServerWidget(),
],
);
return Container(
height: height,
child: Obx(() => isIncomingOnly
? Column(
children: [
basicWidget(),
Align(
child: startServiceWidget(),
alignment: Alignment.centerLeft)
.marginOnly(top: 2.0, left: 22.0),
],
)
: basicWidget()),
).paddingOnly(right: isIncomingOnly ? 8 : 0);
}
_buildConnStatusMsg() {
widget.onSvcStatusChanged?.call();
return Text(
_svcStopped.value
? translate("Service is not running")
: stateGlobal.svcStatus.value == SvcStatus.connecting
? translate("connecting_status")
: stateGlobal.svcStatus.value == SvcStatus.notReady
? translate("not_ready_status")
: translate('Ready'),
style: TextStyle(fontSize: em),
);
}
updateStatus() async {
final status =
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
final statusNum = status['status_num'] as int;
final preStatus = stateGlobal.svcStatus.value;
if (statusNum == 0) {
stateGlobal.svcStatus.value = SvcStatus.connecting;
} else if (statusNum == -1) {
stateGlobal.svcStatus.value = SvcStatus.notReady;
} else if (statusNum == 1) {
stateGlobal.svcStatus.value = SvcStatus.ready;
if (preStatus != SvcStatus.ready) {
gFFI.userModel.refreshCurrentUser();
}
} else {
stateGlobal.svcStatus.value = SvcStatus.notReady;
}
_svcIsUsingPublicServer.value = await bind.mainIsUsingPublicServer();
}
}
/// Connection page for connecting to a remote peer. /// Connection page for connecting to a remote peer.
class ConnectionPage extends StatefulWidget { class ConnectionPage extends StatefulWidget {
const ConnectionPage({Key? key}) : super(key: key); const ConnectionPage({Key? key}) : super(key: key);
@@ -34,13 +200,8 @@ class _ConnectionPageState extends State<ConnectionPage>
/// Controller for the id input bar. /// Controller for the id input bar.
final _idController = IDTextEditingController(); final _idController = IDTextEditingController();
Timer? _updateTimer;
final RxBool _idInputFocused = false.obs; final RxBool _idInputFocused = false.obs;
var svcStopped = Get.find<RxBool>(tag: 'stop-service');
var svcIsUsingPublicServer = true.obs;
bool isWindowMinimized = false; bool isWindowMinimized = false;
List<Peer> peers = []; List<Peer> peers = [];
@@ -60,9 +221,6 @@ class _ConnectionPageState extends State<ConnectionPage>
} }
}(); }();
} }
_updateTimer = periodic_immediate(Duration(seconds: 1), () async {
updateStatus();
});
Get.put<IDTextEditingController>(_idController); Get.put<IDTextEditingController>(_idController);
windowManager.addListener(this); windowManager.addListener(this);
} }
@@ -70,7 +228,6 @@ class _ConnectionPageState extends State<ConnectionPage>
@override @override
void dispose() { void dispose() {
_idController.dispose(); _idController.dispose();
_updateTimer?.cancel();
windowManager.removeListener(this); windowManager.removeListener(this);
if (Get.isRegistered<IDTextEditingController>()) { if (Get.isRegistered<IDTextEditingController>()) {
Get.delete<IDTextEditingController>(); Get.delete<IDTextEditingController>();
@@ -87,7 +244,7 @@ class _ConnectionPageState extends State<ConnectionPage>
if (eventName == 'minimize') { if (eventName == 'minimize') {
isWindowMinimized = true; isWindowMinimized = true;
} else if (eventName == 'maximize' || eventName == 'restore') { } else if (eventName == 'maximize' || eventName == 'restore') {
if (isWindowMinimized && Platform.isWindows) { if (isWindowMinimized && isWindows) {
// windows can't update when minimized. // windows can't update when minimized.
Get.forceAppUpdate(); Get.forceAppUpdate();
} }
@@ -105,7 +262,7 @@ class _ConnectionPageState extends State<ConnectionPage>
void onWindowLeaveFullScreen() { void onWindowLeaveFullScreen() {
// Restore edge border to default edge size. // Restore edge border to default edge size.
stateGlobal.resizeEdgeSize.value = stateGlobal.resizeEdgeSize.value =
stateGlobal.isMaximized.isTrue ? kMaximizeEdgeSize : kWindowEdgeSize; stateGlobal.isMaximized.isTrue ? kMaximizeEdgeSize : windowEdgeSize;
} }
@override @override
@@ -116,6 +273,7 @@ class _ConnectionPageState extends State<ConnectionPage>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isOutgoingOnly = bind.isOutgoingOnly();
return Column( return Column(
children: [ children: [
Expanded( Expanded(
@@ -131,8 +289,8 @@ class _ConnectionPageState extends State<ConnectionPage>
Expanded(child: PeerTabPage()), Expanded(child: PeerTabPage()),
], ],
).paddingOnly(left: 12.0)), ).paddingOnly(left: 12.0)),
const Divider(height: 1), if (!isOutgoingOnly) const Divider(height: 1),
buildStatus() if (!isOutgoingOnly) OnlineStatusWidget()
], ],
); );
} }
@@ -214,6 +372,7 @@ class _ConnectionPageState extends State<ConnectionPage>
platform: '', platform: '',
tags: [], tags: [],
hash: '', hash: '',
password: '',
forceAlwaysRelay: false, forceAlwaysRelay: false,
rdpPort: '', rdpPort: '',
rdpUsername: '', rdpUsername: '',
@@ -289,6 +448,9 @@ class _ConnectionPageState extends State<ConnectionPage>
onChanged: (v) { onChanged: (v) {
_idController.id = v; _idController.id = v;
}, },
onSubmitted: (_) {
onConnect();
},
)); ));
}, },
onSelected: (option) { onSelected: (option) {
@@ -383,111 +545,4 @@ class _ConnectionPageState extends State<ConnectionPage>
return Container( return Container(
constraints: const BoxConstraints(maxWidth: 600), child: w); constraints: const BoxConstraints(maxWidth: 600), child: w);
} }
Widget buildStatus() {
final em = 14.0;
return Container(
height: 3 * em,
child: Obx(() => Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
height: 8,
width: 8,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
color: svcStopped.value ||
stateGlobal.svcStatus.value == SvcStatus.connecting
? kColorWarn
: (stateGlobal.svcStatus.value == SvcStatus.ready
? Color.fromARGB(255, 50, 190, 166)
: Color.fromARGB(255, 224, 79, 95)),
),
).marginSymmetric(horizontal: em),
Text(
svcStopped.value
? translate("Service is not running")
: stateGlobal.svcStatus.value == SvcStatus.connecting
? translate("connecting_status")
: stateGlobal.svcStatus.value == SvcStatus.notReady
? translate("not_ready_status")
: translate('Ready'),
style: TextStyle(fontSize: em)),
// stop
Offstage(
offstage: !svcStopped.value,
child: InkWell(
onTap: () async {
await start_service(true);
},
child: Text(translate("Start service"),
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: em)))
.marginOnly(left: em),
),
// ready && public
Flexible(
child: Offstage(
offstage: !(!svcStopped.value &&
stateGlobal.svcStatus.value == SvcStatus.ready &&
svcIsUsingPublicServer.value),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(', ', style: TextStyle(fontSize: em)),
Flexible(
child: InkWell(
onTap: onUsePublicServerGuide,
child: Row(
children: [
Flexible(
child: Text(
translate('setup_server_tip'),
style: TextStyle(
decoration: TextDecoration.underline,
fontSize: em),
),
),
],
),
),
)
],
),
),
)
],
)),
);
}
void onUsePublicServerGuide() {
const url = "https://rustdesk.com/pricing.html";
canLaunchUrlString(url).then((can) {
if (can) {
launchUrlString(url);
}
});
}
updateStatus() async {
final status =
jsonDecode(await bind.mainGetConnectStatus()) as Map<String, dynamic>;
final statusNum = status['status_num'] as int;
final preStatus = stateGlobal.svcStatus.value;
if (statusNum == 0) {
stateGlobal.svcStatus.value = SvcStatus.connecting;
} else if (statusNum == -1) {
stateGlobal.svcStatus.value = SvcStatus.notReady;
} else if (statusNum == 1) {
stateGlobal.svcStatus.value = SvcStatus.ready;
if (preStatus != SvcStatus.ready) {
gFFI.userModel.refreshCurrentUser();
}
} else {
stateGlobal.svcStatus.value = SvcStatus.notReady;
}
svcIsUsingPublicServer.value = await bind.mainIsUsingPublicServer();
}
} }

View File

@@ -20,6 +20,7 @@ import 'package:flutter_hbb/utils/multi_window_manager.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:window_manager/window_manager.dart';
import 'package:window_size/window_size.dart' as window_size; import 'package:window_size/window_size.dart' as window_size;
import '../widgets/button.dart'; import '../widgets/button.dart';
@@ -50,50 +51,120 @@ class _DesktopHomePageState extends State<DesktopHomePage>
Timer? _updateTimer; Timer? _updateTimer;
bool isCardClosed = false; bool isCardClosed = false;
final RxBool _editHover = false.obs;
final GlobalKey _childKey = GlobalKey();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
final isIncomingOnly = bind.isIncomingOnly();
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
buildLeftPane(context), buildLeftPane(context),
const VerticalDivider(width: 1), if (!isIncomingOnly) const VerticalDivider(width: 1),
Expanded( if (!isIncomingOnly) Expanded(child: buildRightPane(context)),
child: buildRightPane(context),
),
], ],
); );
} }
Widget buildLeftPane(BuildContext context) { Widget buildLeftPane(BuildContext context) {
final isIncomingOnly = bind.isIncomingOnly();
final isOutgoingOnly = bind.isOutgoingOnly();
final children = <Widget>[
if (!isOutgoingOnly) buildPresetPasswordWarning(),
if (bind.isCustomClient())
Align(
alignment: Alignment.center,
child: loadPowered(context),
),
Align(
alignment: Alignment.center,
child: loadLogo(),
),
buildTip(context),
if (!isOutgoingOnly) buildIDBoard(context),
if (!isOutgoingOnly) buildPasswordBoard(context),
FutureBuilder<Widget>(
future: buildHelpCards(),
builder: (_, data) {
if (data.hasData) {
if (isIncomingOnly) {
if (isInHomePage()) {
Future.delayed(Duration(milliseconds: 300), () {
_updateWindowSize();
});
}
}
return data.data!;
} else {
return const Offstage();
}
},
),
buildPluginEntry(),
];
if (isIncomingOnly) {
children.addAll([
Divider(),
OnlineStatusWidget(
onSvcStatusChanged: () {
if (isInHomePage()) {
Future.delayed(Duration(milliseconds: 300), () {
_updateWindowSize();
});
}
},
).marginOnly(bottom: 6, right: 6)
]);
}
final textColor = Theme.of(context).textTheme.titleLarge?.color;
return ChangeNotifierProvider.value( return ChangeNotifierProvider.value(
value: gFFI.serverModel, value: gFFI.serverModel,
child: Container( child: Container(
width: 200, width: isIncomingOnly ? 280.0 : 200.0,
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
child: DesktopScrollWrapper( child: DesktopScrollWrapper(
scrollController: _leftPaneScrollController, scrollController: _leftPaneScrollController,
child: SingleChildScrollView( child: Stack(
controller: _leftPaneScrollController, children: [
physics: DraggableNeverScrollableScrollPhysics(), SingleChildScrollView(
child: Column( controller: _leftPaneScrollController,
children: [ physics: DraggableNeverScrollableScrollPhysics(),
buildTip(context), child: Column(
buildIDBoard(context), key: _childKey,
buildPasswordBoard(context), children: children,
FutureBuilder<Widget>(
future: buildHelpCards(),
builder: (_, data) {
if (data.hasData) {
return data.data!;
} else {
return const Offstage();
}
},
), ),
buildPluginEntry() ),
], if (isOutgoingOnly)
), Positioned(
bottom: 6,
left: 12,
child: Align(
alignment: Alignment.centerLeft,
child: InkWell(
child: Obx(
() => Icon(
Icons.settings,
color: _editHover.value
? textColor
: Colors.grey.withOpacity(0.5),
size: 22,
),
),
onTap: () => {
if (DesktopSettingPage.tabKeys.isNotEmpty)
{
DesktopSettingPage.switch2page(
DesktopSettingPage.tabKeys[0])
}
},
onHover: (value) => _editHover.value = value,
),
),
)
],
), ),
), ),
), ),
@@ -180,19 +251,20 @@ class _DesktopHomePageState extends State<DesktopHomePage>
RxBool hover = false.obs; RxBool hover = false.obs;
return InkWell( return InkWell(
onTap: DesktopTabPage.onAddSetting, onTap: DesktopTabPage.onAddSetting,
child: Obx( child: Tooltip(
() => CircleAvatar( message: translate('Settings'),
radius: 15, child: Obx(
backgroundColor: hover.value () => CircleAvatar(
? Theme.of(context).scaffoldBackgroundColor radius: 15,
: Theme.of(context).colorScheme.background, backgroundColor: hover.value
child: Tooltip( ? Theme.of(context).scaffoldBackgroundColor
message: translate('Settings'), : Theme.of(context).colorScheme.background,
child: Icon( child: Icon(
Icons.more_vert_outlined, Icons.more_vert_outlined,
size: 20, size: 20,
color: hover.value ? textColor : textColor?.withOpacity(0.5), color: hover.value ? textColor : textColor?.withOpacity(0.5),
)), ),
),
), ),
), ),
onHover: (value) => hover.value = value, onHover: (value) => hover.value = value,
@@ -253,34 +325,38 @@ class _DesktopHomePageState extends State<DesktopHomePage>
), ),
AnimatedRotationWidget( AnimatedRotationWidget(
onPressed: () => bind.mainUpdateTemporaryPassword(), onPressed: () => bind.mainUpdateTemporaryPassword(),
child: Obx(() => RotatedBox( child: Tooltip(
quarterTurns: 2, message: translate('Refresh Password'),
child: Tooltip( child: Obx(() => RotatedBox(
message: translate('Refresh Password'), quarterTurns: 2,
child: Icon( child: Icon(
Icons.refresh, Icons.refresh,
color: refreshHover.value color: refreshHover.value
? textColor ? textColor
: Color(0xFFDDDDDD), : Color(0xFFDDDDDD),
size: 22, size: 22,
)))), ))),
),
onHover: (value) => refreshHover.value = value, onHover: (value) => refreshHover.value = value,
).marginOnly(right: 8, top: 4), ).marginOnly(right: 8, top: 4),
InkWell( if (!bind.isDisableSettings())
child: Obx( InkWell(
() => Tooltip( child: Tooltip(
message: translate('Change Password'), message: translate('Change Password'),
child: Icon( child: Obx(
() => Icon(
Icons.edit, Icons.edit,
color: editHover.value color: editHover.value
? textColor ? textColor
: Color(0xFFDDDDDD), : Color(0xFFDDDDDD),
size: 22, size: 22,
)).marginOnly(right: 8, top: 4), ).marginOnly(right: 8, top: 4),
),
),
onTap: () => DesktopSettingPage.switch2page(
SettingsTabKey.safety),
onHover: (value) => editHover.value = value,
), ),
onTap: () => DesktopSettingPage.switch2page(1),
onHover: (value) => editHover.value = value,
),
], ],
), ),
], ],
@@ -293,6 +369,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
buildTip(BuildContext context) { buildTip(BuildContext context) {
final isOutgoingOnly = bind.isOutgoingOnly();
return Padding( return Padding(
padding: padding:
const EdgeInsets.only(left: 20.0, right: 16, top: 16.0, bottom: 5), const EdgeInsets.only(left: 20.0, right: 16, top: 16.0, bottom: 5),
@@ -300,29 +377,43 @@ class _DesktopHomePageState extends State<DesktopHomePage>
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Column(
translate("Your Desktop"), children: [
style: Theme.of(context).textTheme.titleLarge, if (!isOutgoingOnly)
// style: TextStyle( Align(
// // color: MyTheme.color(context).text, alignment: Alignment.centerLeft,
// fontWeight: FontWeight.normal, child: Text(
// fontSize: 19), translate("Your Desktop"),
style: Theme.of(context).textTheme.titleLarge,
),
),
],
), ),
SizedBox( SizedBox(
height: 10.0, height: 10.0,
), ),
Text( if (!isOutgoingOnly)
translate("desk_tip"), Text(
overflow: TextOverflow.clip, translate("desk_tip"),
style: Theme.of(context).textTheme.bodySmall, overflow: TextOverflow.clip,
) style: Theme.of(context).textTheme.bodySmall,
),
if (isOutgoingOnly)
Text(
translate("outgoing_only_desk_tip"),
overflow: TextOverflow.clip,
style: Theme.of(context).textTheme.bodySmall,
),
], ],
), ),
); );
} }
Future<Widget> buildHelpCards() async { Future<Widget> buildHelpCards() async {
if (updateUrl.isNotEmpty && !isCardClosed) { if (!bind.isCustomClient() &&
updateUrl.isNotEmpty &&
!isCardClosed &&
bind.mainUriPrefixSync().contains('rustdesk')) {
return buildInstallCard( return buildInstallCard(
"Status", "Status",
"There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.", "There is a newer version of ${bind.mainGetAppNameSync()} ${bind.mainGetNewVersion()} available.",
@@ -334,9 +425,12 @@ class _DesktopHomePageState extends State<DesktopHomePage>
if (systemError.isNotEmpty) { if (systemError.isNotEmpty) {
return buildInstallCard("", systemError, "", () {}); return buildInstallCard("", systemError, "", () {});
} }
if (Platform.isWindows) {
if (isWindows && !bind.isDisableInstallation()) {
if (!bind.mainIsInstalled()) { if (!bind.mainIsInstalled()) {
return buildInstallCard("", "install_tip", "Install", () async { return buildInstallCard(
"", bind.isOutgoingOnly() ? "" : "install_tip", "Install",
() async {
await rustDeskWinManager.closeAllSubWindows(); await rustDeskWinManager.closeAllSubWindows();
bind.mainGotoInstall(); bind.mainGotoInstall();
}); });
@@ -348,8 +442,9 @@ class _DesktopHomePageState extends State<DesktopHomePage>
bind.mainUpdateMe(); bind.mainUpdateMe();
}); });
} }
} else if (Platform.isMacOS) { } else if (isMacOS) {
if (!bind.mainIsCanScreenRecording(prompt: false)) { if (!(bind.isOutgoingOnly() ||
bind.mainIsCanScreenRecording(prompt: false))) {
return buildInstallCard("Permissions", "config_screen", "Configure", return buildInstallCard("Permissions", "config_screen", "Configure",
() async { () async {
bind.mainIsCanScreenRecording(prompt: true); bind.mainIsCanScreenRecording(prompt: true);
@@ -383,7 +478,10 @@ class _DesktopHomePageState extends State<DesktopHomePage>
// watchIsCanRecordAudio = true; // watchIsCanRecordAudio = true;
// }); // });
// } // }
} else if (Platform.isLinux) { } else if (isLinux) {
if (bind.isOutgoingOnly()) {
return Container();
}
final LinuxCards = <Widget>[]; final LinuxCards = <Widget>[];
if (bind.isSelinuxEnforcing()) { if (bind.isSelinuxEnforcing()) {
// Check is SELinux enforcing, but show user a tip of is SELinux enabled for simple. // Check is SELinux enforcing, but show user a tip of is SELinux enabled for simple.
@@ -422,6 +520,21 @@ class _DesktopHomePageState extends State<DesktopHomePage>
); );
} }
} }
if (bind.isIncomingOnly()) {
return Align(
alignment: Alignment.centerRight,
child: OutlinedButton(
onPressed: () {
SystemNavigator.pop(); // Close the application
// https://github.com/flutter/flutter/issues/66631
if (isWindows) {
exit(0);
}
},
child: Text(translate('Quit')),
),
).marginAll(14);
}
return Container(); return Container();
} }
@@ -450,7 +563,8 @@ class _DesktopHomePageState extends State<DesktopHomePage>
return Stack( return Stack(
children: [ children: [
Container( Container(
margin: EdgeInsets.only(top: marginTop), margin: EdgeInsets.fromLTRB(
0, marginTop, 0, bind.isIncomingOnly() ? marginTop : 0),
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
@@ -478,14 +592,15 @@ class _DesktopHomePageState extends State<DesktopHomePage>
] ]
: <Widget>[]) + : <Widget>[]) +
<Widget>[ <Widget>[
Text( if (content.isNotEmpty)
translate(content), Text(
style: TextStyle( translate(content),
height: 1.5, style: TextStyle(
color: Colors.white, height: 1.5,
fontWeight: FontWeight.normal, color: Colors.white,
fontSize: 13), fontWeight: FontWeight.normal,
).marginOnly(bottom: 20) fontSize: 13),
).marginOnly(bottom: 20)
] + ] +
(btnText.isNotEmpty (btnText.isNotEmpty
? <Widget>[ ? <Widget>[
@@ -582,7 +697,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
} }
} }
if (watchIsCanRecordAudio) { if (watchIsCanRecordAudio) {
if (Platform.isMacOS) { if (isMacOS) {
Future.microtask(() async { Future.microtask(() async {
if ((await osxCanRecordAudio() == if ((await osxCanRecordAudio() ==
PermissionAuthorizeType.authorized)) { PermissionAuthorizeType.authorized)) {
@@ -642,6 +757,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
isFileTransfer: call.arguments['isFileTransfer'], isFileTransfer: call.arguments['isFileTransfer'],
isTcpTunneling: call.arguments['isTcpTunneling'], isTcpTunneling: call.arguments['isTcpTunneling'],
isRDP: call.arguments['isRDP'], isRDP: call.arguments['isRDP'],
password: call.arguments['password'],
forceRelay: call.arguments['forceRelay'], forceRelay: call.arguments['forceRelay'],
); );
} else if (call.method == kWindowEventMoveTabToNewWindow) { } else if (call.method == kWindowEventMoveTabToNewWindow) {
@@ -665,9 +781,35 @@ class _DesktopHomePageState extends State<DesktopHomePage>
final screenRect = parseParamScreenRect(args); final screenRect = parseParamScreenRect(args);
await rustDeskWinManager.openMonitorSession( await rustDeskWinManager.openMonitorSession(
windowId, peerId, display, displayCount, screenRect); windowId, peerId, display, displayCount, screenRect);
} else if (call.method == kWindowEventRemoteWindowCoords) {
final windowId = int.tryParse(call.arguments);
if (windowId != null) {
return jsonEncode(
await rustDeskWinManager.getOtherRemoteWindowCoords(windowId));
}
} }
}); });
_uniLinksSubscription = listenUniLinks(); _uniLinksSubscription = listenUniLinks();
if (bind.isIncomingOnly()) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_updateWindowSize();
});
}
}
_updateWindowSize() {
RenderObject? renderObject = _childKey.currentContext?.findRenderObject();
if (renderObject == null) {
return;
}
if (renderObject is RenderBox) {
final size = renderObject.size;
if (size != imcomingOnlyHomeSize) {
imcomingOnlyHomeSize = size;
windowManager.setSize(getIncomingOnlyHomeSize());
}
}
} }
@override @override

View File

@@ -6,6 +6,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/common/widgets/audio_input.dart';
import 'package:flutter_hbb/common/widgets/setting_widgets.dart'; import 'package:flutter_hbb/common/widgets/setting_widgets.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart'; import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
@@ -36,34 +37,57 @@ const double _kTitleFontSize = 20;
const double _kContentFontSize = 15; const double _kContentFontSize = 15;
const Color _accentColor = MyTheme.accent; const Color _accentColor = MyTheme.accent;
const String _kSettingPageControllerTag = 'settingPageController'; const String _kSettingPageControllerTag = 'settingPageController';
const String _kSettingPageIndexTag = 'settingPageIndex'; const String _kSettingPageTabKeyTag = 'settingPageTabKey';
const int _kPageCount = 6;
class _TabInfo { class _TabInfo {
late final SettingsTabKey key;
late final String label; late final String label;
late final IconData unselected; late final IconData unselected;
late final IconData selected; late final IconData selected;
_TabInfo(this.label, this.unselected, this.selected); _TabInfo(this.key, this.label, this.unselected, this.selected);
}
enum SettingsTabKey {
general,
safety,
network,
display,
plugin,
account,
about,
} }
class DesktopSettingPage extends StatefulWidget { class DesktopSettingPage extends StatefulWidget {
final int initialPage; final SettingsTabKey initialTabkey;
static final List<SettingsTabKey> tabKeys = [
SettingsTabKey.general,
if (!bind.isOutgoingOnly() && !bind.isDisableSettings())
SettingsTabKey.safety,
if (!bind.isDisableSettings()) SettingsTabKey.network,
if (!bind.isIncomingOnly()) SettingsTabKey.display,
if (!isWeb && !bind.isIncomingOnly() && bind.pluginFeatureIsEnabled())
SettingsTabKey.plugin,
if (!bind.isDisableAccount()) SettingsTabKey.account,
SettingsTabKey.about,
];
const DesktopSettingPage({Key? key, required this.initialPage}) DesktopSettingPage({Key? key, required this.initialTabkey}) : super(key: key);
: super(key: key);
@override @override
State<DesktopSettingPage> createState() => _DesktopSettingPageState(); State<DesktopSettingPage> createState() => _DesktopSettingPageState();
static void switch2page(int page) { static void switch2page(SettingsTabKey page) {
if (page >= _kPageCount) return;
try { try {
int index = tabKeys.indexOf(page);
if (index == -1) {
return;
}
if (Get.isRegistered<PageController>(tag: _kSettingPageControllerTag)) { if (Get.isRegistered<PageController>(tag: _kSettingPageControllerTag)) {
DesktopTabPage.onAddSetting(initialPage: page); DesktopTabPage.onAddSetting(initialPage: page);
PageController controller = Get.find(tag: _kSettingPageControllerTag); PageController controller = Get.find(tag: _kSettingPageControllerTag);
RxInt selectedIndex = Get.find(tag: _kSettingPageIndexTag); Rx<SettingsTabKey> selected = Get.find(tag: _kSettingPageTabKeyTag);
selectedIndex.value = page; selected.value = page;
controller.jumpToPage(page); controller.jumpToPage(index);
} else { } else {
DesktopTabPage.onAddSetting(initialPage: page); DesktopTabPage.onAddSetting(initialPage: page);
} }
@@ -76,7 +100,7 @@ class DesktopSettingPage extends StatefulWidget {
class _DesktopSettingPageState extends State<DesktopSettingPage> class _DesktopSettingPageState extends State<DesktopSettingPage>
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
late PageController controller; late PageController controller;
late RxInt selectedIndex; late Rx<SettingsTabKey> selectedTab;
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
@@ -84,14 +108,20 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
@override @override
void initState() { void initState() {
super.initState(); super.initState();
selectedIndex = var initialIndex = DesktopSettingPage.tabKeys.indexOf(widget.initialTabkey);
(widget.initialPage < _kPageCount ? widget.initialPage : 0).obs; if (initialIndex == -1) {
Get.put<RxInt>(selectedIndex, tag: _kSettingPageIndexTag); initialIndex = 0;
controller = PageController(initialPage: widget.initialPage); }
selectedTab = DesktopSettingPage.tabKeys[initialIndex].obs;
Get.put<Rx<SettingsTabKey>>(selectedTab, tag: _kSettingPageTabKeyTag);
controller = PageController(initialPage: initialIndex);
Get.put<PageController>(controller, tag: _kSettingPageControllerTag); Get.put<PageController>(controller, tag: _kSettingPageControllerTag);
controller.addListener(() { controller.addListener(() {
if (controller.page != null) { if (controller.page != null) {
selectedIndex.value = controller.page!.toInt(); int page = controller.page!.toInt();
if (page < DesktopSettingPage.tabKeys.length) {
selectedTab.value = DesktopSettingPage.tabKeys[page];
}
} }
}); });
} }
@@ -100,23 +130,42 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
void dispose() { void dispose() {
super.dispose(); super.dispose();
Get.delete<PageController>(tag: _kSettingPageControllerTag); Get.delete<PageController>(tag: _kSettingPageControllerTag);
Get.delete<RxInt>(tag: _kSettingPageIndexTag); Get.delete<RxInt>(tag: _kSettingPageTabKeyTag);
} }
List<_TabInfo> _settingTabs() { List<_TabInfo> _settingTabs() {
final List<_TabInfo> settingTabs = <_TabInfo>[ final List<_TabInfo> settingTabs = <_TabInfo>[];
_TabInfo('General', Icons.settings_outlined, Icons.settings), for (final tab in DesktopSettingPage.tabKeys) {
_TabInfo('Security', Icons.enhanced_encryption_outlined, switch (tab) {
Icons.enhanced_encryption), case SettingsTabKey.general:
_TabInfo('Network', Icons.link_outlined, Icons.link), settingTabs.add(_TabInfo(
_TabInfo( tab, 'General', Icons.settings_outlined, Icons.settings));
'Display', Icons.desktop_windows_outlined, Icons.desktop_windows), break;
_TabInfo('Account', Icons.person_outline, Icons.person), case SettingsTabKey.safety:
_TabInfo('About', Icons.info_outline, Icons.info) settingTabs.add(_TabInfo(tab, 'Security',
]; Icons.enhanced_encryption_outlined, Icons.enhanced_encryption));
if (bind.pluginFeatureIsEnabled()) { break;
settingTabs.insert( case SettingsTabKey.network:
4, _TabInfo('Plugin', Icons.extension_outlined, Icons.extension)); settingTabs
.add(_TabInfo(tab, 'Network', Icons.link_outlined, Icons.link));
break;
case SettingsTabKey.display:
settingTabs.add(_TabInfo(tab, 'Display',
Icons.desktop_windows_outlined, Icons.desktop_windows));
break;
case SettingsTabKey.plugin:
settingTabs.add(_TabInfo(
tab, 'Plugin', Icons.extension_outlined, Icons.extension));
break;
case SettingsTabKey.account:
settingTabs.add(
_TabInfo(tab, 'Account', Icons.person_outline, Icons.person));
break;
case SettingsTabKey.about:
settingTabs
.add(_TabInfo(tab, 'About', Icons.info_outline, Icons.info));
break;
}
} }
return settingTabs; return settingTabs;
} }
@@ -124,15 +173,14 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
List<Widget> _children() { List<Widget> _children() {
final children = [ final children = [
_General(), _General(),
_Safety(), if (!bind.isOutgoingOnly() && !bind.isDisableSettings()) _Safety(),
_Network(), if (!bind.isDisableSettings()) _Network(),
_Display(), if (!bind.isIncomingOnly()) _Display(),
_Account(), if (!isWeb && !bind.isIncomingOnly() && bind.pluginFeatureIsEnabled())
_Plugin(),
if (!bind.isDisableAccount()) _Account(),
_About(), _About(),
]; ];
if (bind.pluginFeatureIsEnabled()) {
children.insert(4, _Plugin());
}
return children; return children;
} }
@@ -197,26 +245,26 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
child: ListView( child: ListView(
physics: DraggableNeverScrollableScrollPhysics(), physics: DraggableNeverScrollableScrollPhysics(),
controller: scrollController, controller: scrollController,
children: tabs children: tabs.map((tab) => _listItem(tab: tab)).toList(),
.asMap()
.entries
.map((tab) => _listItem(tab: tab.value, index: tab.key))
.toList(),
)); ));
} }
Widget _listItem({required _TabInfo tab, required int index}) { Widget _listItem({required _TabInfo tab}) {
return Obx(() { return Obx(() {
bool selected = index == selectedIndex.value; bool selected = tab.key == selectedTab.value;
return SizedBox( return SizedBox(
width: _kTabWidth, width: _kTabWidth,
height: _kTabHeight, height: _kTabHeight,
child: InkWell( child: InkWell(
onTap: () { onTap: () {
if (selectedIndex.value != index) { if (selectedTab.value != tab.key) {
int index = DesktopSettingPage.tabKeys.indexOf(tab.key);
if (index == -1) {
return;
}
controller.jumpToPage(index); controller.jumpToPage(index);
} }
selectedIndex.value = index; selectedTab.value = tab.key;
}, },
child: Row(children: [ child: Row(children: [
Container( Container(
@@ -270,6 +318,7 @@ class _GeneralState extends State<_General> {
hwcodec(), hwcodec(),
audio(context), audio(context),
record(context), record(context),
WaylandCard(),
_Card(title: 'Language', children: [language()]), _Card(title: 'Language', children: [language()]),
other() other()
], ],
@@ -303,6 +352,10 @@ class _GeneralState extends State<_General> {
} }
Widget service() { Widget service() {
if (bind.isOutgoingOnly()) {
return const Offstage();
}
return _Card(title: 'Service', children: [ return _Card(title: 'Service', children: [
Obx(() => _Button(serviceStop.value ? 'Start' : 'Stop', () { Obx(() => _Button(serviceStop.value ? 'Start' : 'Stop', () {
() async { () async {
@@ -318,31 +371,34 @@ class _GeneralState extends State<_General> {
} }
Widget other() { Widget other() {
final children = [ final children = <Widget>[
_OptionCheckBox(context, 'Confirm before closing multiple tabs', if (!bind.isIncomingOnly())
'enable-confirm-closing-tabs', _OptionCheckBox(context, 'Confirm before closing multiple tabs',
isServer: false), 'enable-confirm-closing-tabs',
isServer: false),
_OptionCheckBox(context, 'Adaptive bitrate', 'enable-abr'), _OptionCheckBox(context, 'Adaptive bitrate', 'enable-abr'),
wallpaper(), wallpaper(),
_OptionCheckBox( if (!bind.isIncomingOnly()) ...[
context, _OptionCheckBox(
'Open connection in new tab', context,
kOptionOpenNewConnInTabs, 'Open connection in new tab',
isServer: false, kOptionOpenNewConnInTabs,
), isServer: false,
),
// though this is related to GUI, but opengl problem affects all users, so put in config rather than local
Tooltip(
message: translate('software_render_tip'),
child: _OptionCheckBox(context, "Always use software rendering",
'allow-always-software-render'),
),
_OptionCheckBox(
context,
'Check for software update on startup',
'enable-check-update',
isServer: false,
)
],
]; ];
// though this is related to GUI, but opengl problem affects all users, so put in config rather than local
children.add(Tooltip(
message: translate('software_render_tip'),
child: _OptionCheckBox(context, "Always use software rendering",
'allow-always-software-render'),
));
children.add(_OptionCheckBox(
context,
'Check for software update on startup',
'enable-check-update',
isServer: false,
));
if (bind.mainShowOption(key: 'allow-linux-headless')) { if (bind.mainShowOption(key: 'allow-linux-headless')) {
children.add(_OptionCheckBox( children.add(_OptionCheckBox(
context, 'Allow linux headless', 'allow-linux-headless')); context, 'Allow linux headless', 'allow-linux-headless'));
@@ -351,6 +407,10 @@ class _GeneralState extends State<_General> {
} }
Widget wallpaper() { Widget wallpaper() {
if (bind.isOutgoingOnly()) {
return const Offstage();
}
return futureBuilder(future: () async { return futureBuilder(future: () async {
final support = await bind.mainSupportRemoveWallpaper(); final support = await bind.mainSupportRemoveWallpaper();
return support; return support;
@@ -388,48 +448,30 @@ class _GeneralState extends State<_General> {
Widget hwcodec() { Widget hwcodec() {
final hwcodec = bind.mainHasHwcodec(); final hwcodec = bind.mainHasHwcodec();
final gpucodec = bind.mainHasGpucodec(); final vram = bind.mainHasVram();
return Offstage( return Offstage(
offstage: !(hwcodec || gpucodec), offstage: !(hwcodec || vram),
child: _Card(title: 'Hardware Codec', children: [ child: _Card(title: 'Hardware Codec', children: [
_OptionCheckBox(context, 'Enable hardware codec', 'enable-hwcodec') _OptionCheckBox(
context,
'Enable hardware codec',
'enable-hwcodec',
update: () {
if (mainGetBoolOptionSync('enable-hwcodec')) {
bind.mainCheckHwcodec();
}
},
)
]), ]),
); );
} }
Widget audio(BuildContext context) { Widget audio(BuildContext context) {
String getDefault() { if (bind.isOutgoingOnly()) {
if (Platform.isWindows) return translate('System Sound'); return const Offstage();
return '';
} }
Future<String> getValue() async { return AudioInput(builder: (devices, currentDevice, setDevice) {
String device = await bind.mainGetOption(key: 'audio-input');
if (device.isNotEmpty) {
return device;
} else {
return getDefault();
}
}
setDevice(String device) {
if (device == getDefault()) device = '';
bind.mainSetOption(key: 'audio-input', value: device);
}
return futureBuilder(future: () async {
List<String> devices = (await bind.mainGetSoundInputs()).toList();
if (Platform.isWindows) {
devices.insert(0, translate('System Sound'));
}
String current = await getValue();
return {'devices': devices, 'current': current};
}(), hasData: (data) {
String currentDevice = data['current'];
List<String> devices = data['devices'] as List<String>;
if (devices.isEmpty) {
return const Offstage();
}
return _Card(title: 'Audio Input Device', children: [ return _Card(title: 'Audio Input Device', children: [
...devices.map((device) => _Radio<String>(context, ...devices.map((device) => _Radio<String>(context,
value: device, value: device,
@@ -444,42 +486,72 @@ class _GeneralState extends State<_General> {
} }
Widget record(BuildContext context) { Widget record(BuildContext context) {
final showRootDir = isWindows && bind.mainIsInstalled();
return futureBuilder(future: () async { return futureBuilder(future: () async {
String defaultDirectory = await bind.mainDefaultVideoSaveDirectory(); String user_dir = await bind.mainVideoSaveDirectory(root: false);
String root_dir =
showRootDir ? await bind.mainVideoSaveDirectory(root: true) : '';
bool user_dir_exists = await Directory(user_dir).exists();
bool root_dir_exists =
showRootDir ? await Directory(root_dir).exists() : false;
// canLaunchUrl blocked on windows portable, user SYSTEM // canLaunchUrl blocked on windows portable, user SYSTEM
return {'dir': defaultDirectory, 'canlaunch': true}; return {
'user_dir': user_dir,
'root_dir': root_dir,
'user_dir_exists': user_dir_exists,
'root_dir_exists': root_dir_exists,
};
}(), hasData: (data) { }(), hasData: (data) {
Map<String, dynamic> map = data as Map<String, dynamic>; Map<String, dynamic> map = data as Map<String, dynamic>;
String dir = map['dir']!; String user_dir = map['user_dir']!;
String customDirectory = String root_dir = map['root_dir']!;
bind.mainGetOptionSync(key: 'video-save-directory'); bool root_dir_exists = map['root_dir_exists']!;
if (customDirectory.isNotEmpty) { bool user_dir_exists = map['user_dir_exists']!;
dir = customDirectory;
}
bool canlaunch = map['canlaunch']! as bool;
return _Card(title: 'Recording', children: [ return _Card(title: 'Recording', children: [
_OptionCheckBox(context, 'Automatically record incoming sessions', _OptionCheckBox(context, 'Automatically record incoming sessions',
'allow-auto-record-incoming'), 'allow-auto-record-incoming'),
if (showRootDir)
Row(
children: [
Text('${translate("Incoming")}:'),
Expanded(
child: GestureDetector(
onTap: root_dir_exists
? () => launchUrl(Uri.file(root_dir))
: null,
child: Text(
root_dir,
softWrap: true,
style: root_dir_exists
? const TextStyle(
decoration: TextDecoration.underline)
: null,
)).marginOnly(left: 10),
),
],
).marginOnly(left: _kContentHMargin),
Row( Row(
children: [ children: [
Text('${translate("Directory")}:'), Text('${translate(showRootDir ? "Outgoing" : "Directory")}:'),
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
onTap: canlaunch ? () => launchUrl(Uri.file(dir)) : null, onTap: user_dir_exists
? () => launchUrl(Uri.file(user_dir))
: null,
child: Text( child: Text(
dir, user_dir,
softWrap: true, softWrap: true,
style: style: user_dir_exists
const TextStyle(decoration: TextDecoration.underline), ? const TextStyle(decoration: TextDecoration.underline)
: null,
)).marginOnly(left: 10), )).marginOnly(left: 10),
), ),
ElevatedButton( ElevatedButton(
onPressed: () async { onPressed: () async {
String? initialDirectory; String? initialDirectory;
if (await Directory.fromUri(Uri.directory(dir)) if (await Directory.fromUri(Uri.directory(user_dir))
.exists()) { .exists()) {
initialDirectory = dir; initialDirectory = user_dir;
} }
String? selectedDirectory = await FilePicker.platform String? selectedDirectory = await FilePicker.platform
.getDirectoryPath(initialDirectory: initialDirectory); .getDirectoryPath(initialDirectory: initialDirectory);
@@ -690,7 +762,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
_OptionCheckBox( _OptionCheckBox(
context, 'Enable recording session', 'enable-record-session', context, 'Enable recording session', 'enable-record-session',
enabled: enabled, fakeValue: fakeValue), enabled: enabled, fakeValue: fakeValue),
if (Platform.isWindows) if (isWindows)
_OptionCheckBox( _OptionCheckBox(
context, 'Enable blocking user input', 'enable-block-input', context, 'Enable blocking user input', 'enable-block-input',
enabled: enabled, fakeValue: fakeValue), enabled: enabled, fakeValue: fakeValue),
@@ -819,6 +891,10 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
...directIp(context), ...directIp(context),
whitelist(), whitelist(),
...autoDisconnect(context), ...autoDisconnect(context),
if (bind.mainIsInstalled())
_OptionCheckBox(context, 'allow-only-conn-window-open-tip',
'allow-only-conn-window-open',
reverse: false, enabled: enabled),
]); ]);
} }
@@ -830,7 +906,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
bool value = bind.mainIsShareRdp(); bool value = bind.mainIsShareRdp();
return Offstage( return Offstage(
offstage: !(Platform.isWindows && bind.mainIsRdpServiceOpen()), offstage: !(isWindows && bind.mainIsInstalled()),
child: GestureDetector( child: GestureDetector(
child: Row( child: Row(
children: [ children: [
@@ -1088,7 +1164,7 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
child: Column(children: [ child: Column(children: [
server(enabled), server(enabled),
_Card(title: 'Proxy', children: [ _Card(title: 'Proxy', children: [
_Button('Socks5 Proxy', changeSocks5Proxy, _Button('Socks5/Http(s) Proxy', changeSocks5Proxy,
enabled: enabled), enabled: enabled),
]), ]),
]), ]),
@@ -1622,7 +1698,7 @@ class _AboutState extends State<_About> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'Copyright © 2023 Purslane Ltd.\n$license', 'Copyright © ${DateTime.now().toString().substring(0, 4)} Purslane Ltd.\n$license',
style: const TextStyle(color: Colors.white), style: const TextStyle(color: Colors.white),
), ),
Text( Text(
@@ -1780,14 +1856,80 @@ Widget _Radio<T>(BuildContext context,
); );
} }
class WaylandCard extends StatefulWidget {
const WaylandCard({Key? key}) : super(key: key);
@override
State<WaylandCard> createState() => _WaylandCardState();
}
class _WaylandCardState extends State<WaylandCard> {
final restoreTokenKey = 'wayland-restore-token';
@override
Widget build(BuildContext context) {
return futureBuilder(
future: bind.mainHandleWaylandScreencastRestoreToken(
key: restoreTokenKey, value: "get"),
hasData: (restoreToken) {
final children = [
if (restoreToken.isNotEmpty)
_buildClearScreenSelection(context, restoreToken),
];
return Offstage(
offstage: children.isEmpty,
child: _Card(title: 'Wayland', children: children),
);
},
);
}
Widget _buildClearScreenSelection(BuildContext context, String restoreToken) {
onConfirm() async {
final msg = await bind.mainHandleWaylandScreencastRestoreToken(
key: restoreTokenKey, value: "clear");
gFFI.dialogManager.dismissAll();
if (msg.isNotEmpty) {
msgBox(gFFI.sessionId, 'custom-nocancel', 'Error', msg, '',
gFFI.dialogManager);
} else {
setState(() {});
}
}
showConfirmMsgBox() => msgBoxCommon(
gFFI.dialogManager,
'Confirmation',
Text(
translate('confirm_clear_Wayland_screen_selection_tip'),
),
[
dialogButton('OK', onPressed: onConfirm),
dialogButton('Cancel',
onPressed: () => gFFI.dialogManager.dismissAll())
]);
return _Button(
'Clear Wayland screen selection',
showConfirmMsgBox,
tip: 'clear_Wayland_screen_selection_tip',
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).colorScheme.error.withOpacity(0.75)),
),
);
}
}
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
Widget _Button(String label, Function() onPressed, Widget _Button(String label, Function() onPressed,
{bool enabled = true, String? tip}) { {bool enabled = true, String? tip, ButtonStyle? style}) {
var button = ElevatedButton( var button = ElevatedButton(
onPressed: enabled ? onPressed : null, onPressed: enabled ? onPressed : null,
child: Text( child: Text(
translate(label), translate(label),
).marginSymmetric(horizontal: 15), ).marginSymmetric(horizontal: 15),
style: style,
); );
StatefulWidget child; StatefulWidget child;
if (tip == null) { if (tip == null) {
@@ -2004,7 +2146,12 @@ void changeSocks5Proxy() async {
password = pwdController.text.trim(); password = pwdController.text.trim();
if (proxy.isNotEmpty) { if (proxy.isNotEmpty) {
proxyMsg = translate(await bind.mainTestIfValidServer(server: proxy)); String domainPort = proxy;
if (domainPort.contains('://')) {
domainPort = domainPort.split('://')[1];
}
proxyMsg = translate(await bind.mainTestIfValidServer(
server: domainPort, testWithProxy: false));
if (proxyMsg.isEmpty) { if (proxyMsg.isEmpty) {
// ignore // ignore
} else { } else {
@@ -2018,7 +2165,7 @@ void changeSocks5Proxy() async {
} }
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate('Socks5 Proxy')), title: Text(translate('Socks5/Http(s) Proxy')),
content: ConstrainedBox( content: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 500), constraints: const BoxConstraints(minWidth: 500),
child: Column( child: Column(
@@ -2027,15 +2174,35 @@ void changeSocks5Proxy() async {
Row( Row(
children: [ children: [
ConstrainedBox( ConstrainedBox(
constraints: const BoxConstraints(minWidth: 140), constraints: const BoxConstraints(minWidth: 140),
child: Text( child: Align(
'${translate("Hostname")}:', alignment: Alignment.centerRight,
textAlign: TextAlign.right, child: Row(
).marginOnly(right: 10)), children: [
Text(
translate('Server'),
).marginOnly(right: 4),
Tooltip(
waitDuration: Duration(milliseconds: 0),
message: translate("default_proxy_tip"),
child: Icon(
Icons.help_outline_outlined,
size: 16,
color: Theme.of(context)
.textTheme
.titleLarge
?.color
?.withOpacity(0.5),
),
),
],
)).marginOnly(right: 10),
),
Expanded( Expanded(
child: TextField( child: TextField(
decoration: InputDecoration( decoration: InputDecoration(
errorText: proxyMsg.isNotEmpty ? proxyMsg : null), errorText: proxyMsg.isNotEmpty ? proxyMsg : null,
),
controller: proxyController, controller: proxyController,
autofocus: true, autofocus: true,
), ),

View File

@@ -1,11 +1,10 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart'; import 'package:flutter_hbb/desktop/pages/desktop_home_page.dart';
import 'package:flutter_hbb/desktop/pages/desktop_setting_page.dart'; import 'package:flutter_hbb/desktop/pages/desktop_setting_page.dart';
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart'; import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/models/state_model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
@@ -18,7 +17,8 @@ class DesktopTabPage extends StatefulWidget {
@override @override
State<DesktopTabPage> createState() => _DesktopTabPageState(); State<DesktopTabPage> createState() => _DesktopTabPageState();
static void onAddSetting({int initialPage = 0}) { static void onAddSetting(
{SettingsTabKey initialPage = SettingsTabKey.general}) {
try { try {
DesktopTabController tabController = Get.find(); DesktopTabController tabController = Get.find();
tabController.add(TabInfo( tabController.add(TabInfo(
@@ -28,7 +28,7 @@ class DesktopTabPage extends StatefulWidget {
unselectedIcon: Icons.build_outlined, unselectedIcon: Icons.build_outlined,
page: DesktopSettingPage( page: DesktopSettingPage(
key: const ValueKey(kTabLabelSettingPage), key: const ValueKey(kTabLabelSettingPage),
initialPage: initialPage, initialTabkey: initialPage,
))); )));
} catch (e) { } catch (e) {
debugPrintStack(label: '$e'); debugPrintStack(label: '$e');
@@ -53,6 +53,17 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
page: DesktopHomePage( page: DesktopHomePage(
key: const ValueKey(kTabLabelHomePage), key: const ValueKey(kTabLabelHomePage),
))); )));
if (bind.isIncomingOnly()) {
tabController.onSelected = (key) {
if (key == kTabLabelHomePage) {
windowManager.setSize(getIncomingOnlyHomeSize());
setResizable(false);
} else {
windowManager.setSize(getIncomingOnlySettingsSize());
setResizable(true);
}
};
}
} }
@override @override
@@ -68,14 +79,17 @@ class _DesktopTabPageState extends State<DesktopTabPage> {
backgroundColor: Theme.of(context).colorScheme.background, backgroundColor: Theme.of(context).colorScheme.background,
body: DesktopTab( body: DesktopTab(
controller: tabController, controller: tabController,
tail: ActionIcon( tail: Offstage(
message: 'Settings', offstage: bind.isIncomingOnly() || bind.isDisableSettings(),
icon: IconFont.menu, child: ActionIcon(
onTap: DesktopTabPage.onAddSetting, message: 'Settings',
isClose: false, icon: IconFont.menu,
onTap: DesktopTabPage.onAddSetting,
isClose: false,
),
), ),
))); )));
return Platform.isMacOS || kUseCompatibleUiMode return isMacOS || kUseCompatibleUiMode
? tabWidget ? tabWidget
: Obx( : Obx(
() => DragToResizeArea( () => DragToResizeArea(

View File

@@ -53,11 +53,13 @@ class FileManagerPage extends StatefulWidget {
{Key? key, {Key? key,
required this.id, required this.id,
required this.password, required this.password,
required this.isSharedPassword,
required this.tabController, required this.tabController,
this.forceRelay}) this.forceRelay})
: super(key: key); : super(key: key);
final String id; final String id;
final String? password; final String? password;
final bool? isSharedPassword;
final bool? forceRelay; final bool? forceRelay;
final DesktopTabController tabController; final DesktopTabController tabController;
@@ -84,13 +86,14 @@ class _FileManagerPageState extends State<FileManagerPage>
_ffi.start(widget.id, _ffi.start(widget.id,
isFileTransfer: true, isFileTransfer: true,
password: widget.password, password: widget.password,
isSharedPassword: widget.isSharedPassword,
forceRelay: widget.forceRelay); forceRelay: widget.forceRelay);
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
_ffi.dialogManager _ffi.dialogManager
.showLoading(translate('Connecting...'), onCancel: closeConnection); .showLoading(translate('Connecting...'), onCancel: closeConnection);
}); });
Get.put(_ffi, tag: 'ft_${widget.id}'); Get.put(_ffi, tag: 'ft_${widget.id}');
if (!Platform.isLinux) { if (!isLinux) {
WakelockPlus.enable(); WakelockPlus.enable();
} }
debugPrint("File manager page init success with id ${widget.id}"); debugPrint("File manager page init success with id ${widget.id}");
@@ -103,7 +106,7 @@ class _FileManagerPageState extends State<FileManagerPage>
model.close().whenComplete(() { model.close().whenComplete(() {
_ffi.close(); _ffi.close();
_ffi.dialogManager.dismissAll(); _ffi.dialogManager.dismissAll();
if (!Platform.isLinux) { if (!isLinux) {
WakelockPlus.disable(); WakelockPlus.disable();
} }
Get.delete<FFI>(tag: 'ft_${widget.id}'); Get.delete<FFI>(tag: 'ft_${widget.id}');
@@ -1295,7 +1298,7 @@ class _FileManagerViewState extends State<FileManagerView> {
onPointerSignal: (e) { onPointerSignal: (e) {
if (e is PointerScrollEvent) { if (e is PointerScrollEvent) {
final sc = _breadCrumbScroller; final sc = _breadCrumbScroller;
final scale = Platform.isWindows ? 2 : 4; final scale = isWindows ? 2 : 4;
sc.jumpTo(sc.offset + e.scrollDelta.dy / scale); sc.jumpTo(sc.offset + e.scrollDelta.dy / scale);
} }
}, },

View File

@@ -1,5 +1,4 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -45,6 +44,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
key: ValueKey(params['id']), key: ValueKey(params['id']),
id: params['id'], id: params['id'],
password: params['password'], password: params['password'],
isSharedPassword: params['isSharedPassword'],
tabController: tabController, tabController: tabController,
forceRelay: params['forceRelay'], forceRelay: params['forceRelay'],
))); )));
@@ -74,6 +74,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
key: ValueKey(id), key: ValueKey(id),
id: id, id: id,
password: args['password'], password: args['password'],
isSharedPassword: args['isSharedPassword'],
tabController: tabController, tabController: tabController,
forceRelay: args['forceRelay'], forceRelay: args['forceRelay'],
))); )));
@@ -90,19 +91,22 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final tabWidget = Container( final child = Scaffold(
decoration: BoxDecoration( backgroundColor: Theme.of(context).cardColor,
border: Border.all(color: MyTheme.color(context).border!)), body: DesktopTab(
child: Scaffold( controller: tabController,
backgroundColor: Theme.of(context).cardColor, onWindowCloseButton: handleWindowCloseButton,
body: DesktopTab( tail: const AddButton(),
controller: tabController, labelGetter: DesktopTab.tablabelGetter,
onWindowCloseButton: handleWindowCloseButton, ));
tail: const AddButton().paddingOnly(left: 10), final tabWidget = isLinux
labelGetter: DesktopTab.tablabelGetter, ? buildVirtualWindowFrame(context, child)
)), : Container(
); decoration: BoxDecoration(
return Platform.isMacOS || kUseCompatibleUiMode border: Border.all(color: MyTheme.color(context).border!)),
child: child,
);
return isMacOS || kUseCompatibleUiMode
? tabWidget ? tabWidget
: SubWindowDragToResizeArea( : SubWindowDragToResizeArea(
child: tabWidget, child: tabWidget,

View File

@@ -25,19 +25,21 @@ class _PortForward {
} }
class PortForwardPage extends StatefulWidget { class PortForwardPage extends StatefulWidget {
const PortForwardPage( const PortForwardPage({
{Key? key, Key? key,
required this.id, required this.id,
required this.password, required this.password,
required this.tabController, required this.tabController,
required this.isRDP, required this.isRDP,
this.forceRelay}) required this.isSharedPassword,
: super(key: key); this.forceRelay,
}) : super(key: key);
final String id; final String id;
final String? password; final String? password;
final DesktopTabController tabController; final DesktopTabController tabController;
final bool isRDP; final bool isRDP;
final bool? forceRelay; final bool? forceRelay;
final bool? isSharedPassword;
@override @override
State<PortForwardPage> createState() => _PortForwardPageState(); State<PortForwardPage> createState() => _PortForwardPageState();
@@ -58,6 +60,7 @@ class _PortForwardPageState extends State<PortForwardPage>
_ffi.start(widget.id, _ffi.start(widget.id,
isPortForward: true, isPortForward: true,
password: widget.password, password: widget.password,
isSharedPassword: widget.isSharedPassword,
forceRelay: widget.forceRelay, forceRelay: widget.forceRelay,
isRdp: widget.isRDP); isRdp: widget.isRDP);
Get.put(_ffi, tag: 'pf_${widget.id}'); Get.put(_ffi, tag: 'pf_${widget.id}');

View File

@@ -1,5 +1,4 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -44,6 +43,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
key: ValueKey(params['id']), key: ValueKey(params['id']),
id: params['id'], id: params['id'],
password: params['password'], password: params['password'],
isSharedPassword: params['isSharedPassword'],
tabController: tabController, tabController: tabController,
isRDP: isRDP, isRDP: isRDP,
forceRelay: params['forceRelay'], forceRelay: params['forceRelay'],
@@ -79,6 +79,7 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
key: ValueKey(args['id']), key: ValueKey(args['id']),
id: id, id: id,
password: args['password'], password: args['password'],
isSharedPassword: args['isSharedPassword'],
isRDP: isRDP, isRDP: isRDP,
tabController: tabController, tabController: tabController,
forceRelay: args['forceRelay'], forceRelay: args['forceRelay'],
@@ -96,22 +97,31 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final tabWidget = Container( final child = Scaffold(
decoration: BoxDecoration( backgroundColor: Theme.of(context).colorScheme.background,
border: Border.all(color: MyTheme.color(context).border!)), body: DesktopTab(
child: Scaffold( controller: tabController,
backgroundColor: Theme.of(context).colorScheme.background, onWindowCloseButton: () async {
body: DesktopTab( tabController.clear();
controller: tabController, return true;
onWindowCloseButton: () async { },
tabController.clear(); tail: AddButton(),
return true; labelGetter: DesktopTab.tablabelGetter,
}, ),
tail: AddButton().paddingOnly(left: 10),
labelGetter: DesktopTab.tablabelGetter,
)),
); );
return Platform.isMacOS || kUseCompatibleUiMode final tabWidget = isLinux
? buildVirtualWindowFrame(
context,
Scaffold(
backgroundColor: Theme.of(context).colorScheme.background,
body: child),
)
: Container(
decoration: BoxDecoration(
border: Border.all(color: MyTheme.color(context).border!)),
child: child,
);
return isMacOS || kUseCompatibleUiMode
? tabWidget ? tabWidget
: Obx( : Obx(
() => SubWindowDragToResizeArea( () => SubWindowDragToResizeArea(

View File

@@ -1,16 +1,13 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_custom_cursor/cursor_manager.dart'
as custom_cursor_manager;
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:wakelock_plus/wakelock_plus.dart';
import 'package:flutter_custom_cursor/flutter_custom_cursor.dart';
import 'package:flutter_improved_scrolling/flutter_improved_scrolling.dart'; import 'package:flutter_improved_scrolling/flutter_improved_scrolling.dart';
import 'package:flutter_hbb/models/state_model.dart';
import '../../consts.dart'; import '../../consts.dart';
import '../../common/widgets/overlay.dart'; import '../../common/widgets/overlay.dart';
@@ -27,6 +24,9 @@ import '../widgets/remote_toolbar.dart';
import '../widgets/kb_layout_type_chooser.dart'; import '../widgets/kb_layout_type_chooser.dart';
import '../widgets/tabbar_widget.dart'; import '../widgets/tabbar_widget.dart';
import 'package:flutter_hbb/native/custom_cursor.dart'
if (dart.library.html) 'package:flutter_hbb/web/custom_cursor.dart';
final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false); final SimpleWrapper<bool> _firstEnterImage = SimpleWrapper(false);
// Used to skip session close if "move to new window" is clicked. // Used to skip session close if "move to new window" is clicked.
@@ -36,15 +36,16 @@ class RemotePage extends StatefulWidget {
RemotePage({ RemotePage({
Key? key, Key? key,
required this.id, required this.id,
required this.sessionId,
required this.tabWindowId,
required this.display,
required this.displays,
required this.password,
required this.toolbarState, required this.toolbarState,
required this.tabController, this.sessionId,
this.tabWindowId,
this.password,
this.display,
this.displays,
this.tabController,
this.switchUuid, this.switchUuid,
this.forceRelay, this.forceRelay,
this.isSharedPassword,
}) : super(key: key); }) : super(key: key);
final String id; final String id;
@@ -56,8 +57,9 @@ class RemotePage extends StatefulWidget {
final ToolbarState toolbarState; final ToolbarState toolbarState;
final String? switchUuid; final String? switchUuid;
final bool? forceRelay; final bool? forceRelay;
final bool? isSharedPassword;
final SimpleWrapper<State<RemotePage>?> _lastState = SimpleWrapper(null); final SimpleWrapper<State<RemotePage>?> _lastState = SimpleWrapper(null);
final DesktopTabController tabController; final DesktopTabController? tabController;
FFI get ffi => (_lastState.value! as _RemotePageState)._ffi; FFI get ffi => (_lastState.value! as _RemotePageState)._ffi;
@@ -111,6 +113,7 @@ class _RemotePageState extends State<RemotePage>
_ffi.start( _ffi.start(
widget.id, widget.id,
password: widget.password, password: widget.password,
isSharedPassword: widget.isSharedPassword,
switchUuid: widget.switchUuid, switchUuid: widget.switchUuid,
forceRelay: widget.forceRelay, forceRelay: widget.forceRelay,
tabWindowId: widget.tabWindowId, tabWindowId: widget.tabWindowId,
@@ -122,12 +125,12 @@ class _RemotePageState extends State<RemotePage>
_ffi.dialogManager _ffi.dialogManager
.showLoading(translate('Connecting...'), onCancel: closeConnection); .showLoading(translate('Connecting...'), onCancel: closeConnection);
}); });
if (!Platform.isLinux) { if (!isLinux) {
WakelockPlus.enable(); WakelockPlus.enable();
} }
_ffi.ffiModel.updateEventListener(sessionId, widget.id); _ffi.ffiModel.updateEventListener(sessionId, widget.id);
bind.pluginSyncUi(syncTo: kAppTypeDesktopRemote); if (!isWeb) bind.pluginSyncUi(syncTo: kAppTypeDesktopRemote);
_ffi.qualityMonitorModel.checkShowQualityMonitor(sessionId); _ffi.qualityMonitorModel.checkShowQualityMonitor(sessionId);
// Session option should be set after models.dart/FFI.start // Session option should be set after models.dart/FFI.start
_showRemoteCursor.value = bind.sessionGetToggleOptionSync( _showRemoteCursor.value = bind.sessionGetToggleOptionSync(
@@ -148,7 +151,7 @@ class _RemotePageState extends State<RemotePage>
// } // }
_blockableOverlayState.applyFfi(_ffi); _blockableOverlayState.applyFfi(_ffi);
widget.tabController.onSelected?.call(widget.id); widget.tabController?.onSelected?.call(widget.id);
} }
@override @override
@@ -157,21 +160,23 @@ class _RemotePageState extends State<RemotePage>
// On windows, we use `focus` way to handle keyboard better. // On windows, we use `focus` way to handle keyboard better.
// Now on Linux, there's some rdev issues which will break the input. // Now on Linux, there's some rdev issues which will break the input.
// We disable the `focus` way for non-Windows temporarily. // We disable the `focus` way for non-Windows temporarily.
if (Platform.isWindows) { if (isWindows) {
_isWindowBlur = true; _isWindowBlur = true;
// unfocus the primary-focus when the whole window is lost focus, // unfocus the primary-focus when the whole window is lost focus,
// and let OS to handle events instead. // and let OS to handle events instead.
_rawKeyFocusNode.unfocus(); _rawKeyFocusNode.unfocus();
} }
stateGlobal.isFocused.value = false;
} }
@override @override
void onWindowFocus() { void onWindowFocus() {
super.onWindowFocus(); super.onWindowFocus();
// See [onWindowBlur]. // See [onWindowBlur].
if (Platform.isWindows) { if (isWindows) {
_isWindowBlur = false; _isWindowBlur = false;
} }
stateGlobal.isFocused.value = true;
} }
@override @override
@@ -179,10 +184,10 @@ class _RemotePageState extends State<RemotePage>
super.onWindowRestore(); super.onWindowRestore();
// On windows, we use `onWindowRestore` way to handle window restore from // On windows, we use `onWindowRestore` way to handle window restore from
// a minimized state. // a minimized state.
if (Platform.isWindows) { if (isWindows) {
_isWindowBlur = false; _isWindowBlur = false;
} }
if (!Platform.isLinux) { if (!isLinux) {
WakelockPlus.enable(); WakelockPlus.enable();
} }
} }
@@ -191,7 +196,7 @@ class _RemotePageState extends State<RemotePage>
@override @override
void onWindowMaximize() { void onWindowMaximize() {
super.onWindowMaximize(); super.onWindowMaximize();
if (!Platform.isLinux) { if (!isLinux) {
WakelockPlus.enable(); WakelockPlus.enable();
} }
} }
@@ -199,7 +204,7 @@ class _RemotePageState extends State<RemotePage>
@override @override
void onWindowMinimize() { void onWindowMinimize() {
super.onWindowMinimize(); super.onWindowMinimize();
if (!Platform.isLinux) { if (!isLinux) {
WakelockPlus.disable(); WakelockPlus.disable();
} }
} }
@@ -225,7 +230,7 @@ class _RemotePageState extends State<RemotePage>
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: SystemUiOverlay.values); overlays: SystemUiOverlay.values);
} }
if (!Platform.isLinux) { if (!isLinux) {
await WakelockPlus.disable(); await WakelockPlus.disable();
} }
await Get.delete<FFI>(tag: widget.id); await Get.delete<FFI>(tag: widget.id);
@@ -263,7 +268,7 @@ class _RemotePageState extends State<RemotePage>
debugPrint( debugPrint(
"onFocusChange(window active:${!_isWindowBlur}) $imageFocused"); "onFocusChange(window active:${!_isWindowBlur}) $imageFocused");
// See [onWindowBlur]. // See [onWindowBlur].
if (Platform.isWindows) { if (isWindows) {
if (_isWindowBlur) { if (_isWindowBlur) {
imageFocused = false; imageFocused = false;
Future.delayed(Duration.zero, () { Future.delayed(Duration.zero, () {
@@ -359,7 +364,7 @@ class _RemotePageState extends State<RemotePage>
} }
} }
// See [onWindowBlur]. // See [onWindowBlur].
if (!Platform.isWindows) { if (!isWindows) {
if (!_rawKeyFocusNode.hasFocus) { if (!_rawKeyFocusNode.hasFocus) {
_rawKeyFocusNode.requestFocus(); _rawKeyFocusNode.requestFocus();
} }
@@ -382,7 +387,7 @@ class _RemotePageState extends State<RemotePage>
} }
} }
// See [onWindowBlur]. // See [onWindowBlur].
if (!Platform.isWindows) { if (!isWindows) {
_ffi.inputModel.enterOrLeave(false); _ffi.inputModel.enterOrLeave(false);
} }
} }
@@ -429,9 +434,9 @@ class _RemotePageState extends State<RemotePage>
Widget getBodyForDesktop(BuildContext context) { Widget getBodyForDesktop(BuildContext context) {
var paints = <Widget>[ var paints = <Widget>[
MouseRegion(onEnter: (evt) { MouseRegion(onEnter: (evt) {
bind.hostStopSystemKeyPropagate(stopped: false); if (!isWeb) bind.hostStopSystemKeyPropagate(stopped: false);
}, onExit: (evt) { }, onExit: (evt) {
bind.hostStopSystemKeyPropagate(stopped: true); if (!isWeb) bind.hostStopSystemKeyPropagate(stopped: true);
}, child: LayoutBuilder(builder: (context, constraints) { }, child: LayoutBuilder(builder: (context, constraints) {
Future.delayed(Duration.zero, () { Future.delayed(Duration.zero, () {
Provider.of<CanvasModel>(context, listen: false).updateViewStyle(); Provider.of<CanvasModel>(context, listen: false).updateViewStyle();
@@ -534,7 +539,7 @@ class _ImagePaintState extends State<ImagePaint> {
double getCursorScale() { double getCursorScale() {
var c = Provider.of<CanvasModel>(context); var c = Provider.of<CanvasModel>(context);
var cursorScale = 1.0; var cursorScale = 1.0;
if (Platform.isWindows) { if (isWindows) {
// debug win10 // debug win10
if (zoomCursor.value && isViewAdaptive()) { if (zoomCursor.value && isViewAdaptive()) {
cursorScale = s * c.devicePixelRatio; cursorScale = s * c.devicePixelRatio;
@@ -601,8 +606,8 @@ class _ImagePaintState extends State<ImagePaint> {
c, c,
s, s,
Offset( Offset(
Platform.isLinux ? c.x.toInt().toDouble() : c.x, isLinux ? c.x.toInt().toDouble() : c.x,
Platform.isLinux ? c.y.toInt().toDouble() : c.y, isLinux ? c.y.toInt().toDouble() : c.y,
), ),
c.size, c.size,
isViewOriginal()) isViewOriginal())
@@ -665,43 +670,16 @@ class _ImagePaintState extends State<ImagePaint> {
); );
} }
MouseCursor _buildCursorOfCache(
CursorModel cursor, double scale, CursorData? cache) {
if (cache == null) {
return MouseCursor.defer;
} else {
final key = cache.updateGetKey(scale);
if (!cursor.cachedKeys.contains(key)) {
debugPrint(
"Register custom cursor with key $key (${cache.hotx},${cache.hoty})");
// [Safety]
// It's ok to call async registerCursor in current synchronous context,
// because activating the cursor is also an async call and will always
// be executed after this.
custom_cursor_manager.CursorManager.instance
.registerCursor(custom_cursor_manager.CursorData()
..buffer = cache.data!
..height = (cache.height * cache.scale).toInt()
..width = (cache.width * cache.scale).toInt()
..hotX = cache.hotx
..hotY = cache.hoty
..name = key);
cursor.addKey(key);
}
return FlutterCustomMemoryImageCursor(key: key);
}
}
MouseCursor _buildCustomCursor(BuildContext context, double scale) { MouseCursor _buildCustomCursor(BuildContext context, double scale) {
final cursor = Provider.of<CursorModel>(context); final cursor = Provider.of<CursorModel>(context);
final cache = cursor.cache ?? preDefaultCursor.cache; final cache = cursor.cache ?? preDefaultCursor.cache;
return _buildCursorOfCache(cursor, scale, cache); return buildCursorOfCache(cursor, scale, cache);
} }
MouseCursor _buildDisabledCursor(BuildContext context, double scale) { MouseCursor _buildDisabledCursor(BuildContext context, double scale) {
final cursor = Provider.of<CursorModel>(context); final cursor = Provider.of<CursorModel>(context);
final cache = preForbiddenCursor.cache; final cache = preForbiddenCursor.cache;
return _buildCursorOfCache(cursor, scale, cache); return buildCursorOfCache(cursor, scale, cache);
} }
Widget _buildCrossScrollbarFromLayout( Widget _buildCrossScrollbarFromLayout(

View File

@@ -1,6 +1,5 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui; import 'dart:ui' as ui;
import 'package:desktop_multi_window/desktop_multi_window.dart'; import 'package:desktop_multi_window/desktop_multi_window.dart';
@@ -8,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/common/shared_state.dart'; import 'package:flutter_hbb/common/shared_state.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/input_model.dart';
import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/models/state_model.dart';
import 'package:flutter_hbb/desktop/pages/remote_page.dart'; import 'package:flutter_hbb/desktop/pages/remote_page.dart';
import 'package:flutter_hbb/desktop/widgets/remote_toolbar.dart'; import 'package:flutter_hbb/desktop/widgets/remote_toolbar.dart';
@@ -95,6 +95,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
tabController: tabController, tabController: tabController,
switchUuid: params['switch_uuid'], switchUuid: params['switch_uuid'],
forceRelay: params['forceRelay'], forceRelay: params['forceRelay'],
isSharedPassword: params['isSharedPassword'],
), ),
)); ));
_update_remote_count(); _update_remote_count();
@@ -107,106 +108,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
tabController.onRemoved = (_, id) => onRemoveId(id); tabController.onRemoved = (_, id) => onRemoveId(id);
rustDeskWinManager.setMethodHandler((call, fromWindowId) async { rustDeskWinManager.setMethodHandler(_remoteMethodHandler);
print(
"[Remote Page] call ${call.method} with args ${call.arguments} from window $fromWindowId");
dynamic returnValue;
// for simplify, just replace connectionId
if (call.method == kWindowEventNewRemoteDesktop) {
final args = jsonDecode(call.arguments);
final id = args['id'];
final switchUuid = args['switch_uuid'];
final sessionId = args['session_id'];
final tabWindowId = args['tab_window_id'];
final display = args['display'];
final displays = args['displays'];
final screenRect = parseParamScreenRect(args);
windowOnTop(windowId());
tryMoveToScreenAndSetFullscreen(screenRect);
if (tabController.length == 0) {
// Show the hidden window.
if (Platform.isMacOS && stateGlobal.closeOnFullscreen == true) {
stateGlobal.setFullscreen(true);
}
// Reset the state
stateGlobal.closeOnFullscreen = null;
}
ConnectionTypeState.init(id);
_toolbarState.setShow(
bind.mainGetUserDefaultOption(key: 'collapse_toolbar') != 'Y');
tabController.add(TabInfo(
key: id,
label: id,
selectedIcon: selectedIcon,
unselectedIcon: unselectedIcon,
onTabCloseButton: () => tabController.closeBy(id),
page: RemotePage(
key: ValueKey(id),
id: id,
sessionId: sessionId == null ? null : SessionID(sessionId),
tabWindowId: tabWindowId,
display: display,
displays: displays?.cast<int>(),
password: args['password'],
toolbarState: _toolbarState,
tabController: tabController,
switchUuid: switchUuid,
forceRelay: args['forceRelay'],
),
));
} else if (call.method == kWindowDisableGrabKeyboard) {
// ???
} else if (call.method == "onDestroy") {
tabController.clear();
} else if (call.method == kWindowActionRebuild) {
reloadCurrentWindow();
} else if (call.method == kWindowEventActiveSession) {
final jumpOk = tabController.jumpToByKey(call.arguments);
if (jumpOk) {
windowOnTop(windowId());
}
return jumpOk;
} else if (call.method == kWindowEventActiveDisplaySession) {
final args = jsonDecode(call.arguments);
final id = args['id'];
final display = args['display'];
final jumpOk = tabController.jumpToByKeyAndDisplay(id, display);
if (jumpOk) {
windowOnTop(windowId());
}
return jumpOk;
} else if (call.method == kWindowEventGetRemoteList) {
return tabController.state.value.tabs
.map((e) => e.key)
.toList()
.join(',');
} else if (call.method == kWindowEventGetSessionIdList) {
return tabController.state.value.tabs
.map((e) => '${e.key},${(e.page as RemotePage).ffi.sessionId}')
.toList()
.join(';');
} else if (call.method == kWindowEventGetCachedSessionData) {
// Ready to show new window and close old tab.
final args = jsonDecode(call.arguments);
final id = args['id'];
final close = args['close'];
try {
final remotePage = tabController.state.value.tabs
.firstWhere((tab) => tab.key == id)
.page as RemotePage;
returnValue = remotePage.ffi.ffiModel.cachedPeerData.toString();
} catch (e) {
debugPrint('Failed to get cached session data: $e');
}
if (close && returnValue != null) {
closeSessionOnDispose[id] = false;
tabController.closeBy(id);
}
}
_update_remote_count();
return returnValue;
});
if (!_isScreenRectSet) { if (!_isScreenRectSet) {
Future.delayed(Duration.zero, () { Future.delayed(Duration.zero, () {
restoreWindowPosition( restoreWindowPosition(
@@ -229,104 +131,104 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final tabWidget = Obx( final child = Scaffold(
() => Container( backgroundColor: Theme.of(context).colorScheme.background,
decoration: BoxDecoration( body: DesktopTab(
border: Border.all( controller: tabController,
color: MyTheme.color(context).border!, onWindowCloseButton: handleWindowCloseButton,
width: stateGlobal.windowBorderWidth.value), tail: const AddButton(),
), pageViewBuilder: (pageView) => pageView,
child: Scaffold( labelGetter: DesktopTab.tablabelGetter,
backgroundColor: Theme.of(context).colorScheme.background, tabBuilder: (key, icon, label, themeConf) => Obx(() {
body: DesktopTab( final connectionType = ConnectionTypeState.find(key);
controller: tabController, if (!connectionType.isValid()) {
onWindowCloseButton: handleWindowCloseButton, return Row(
tail: const AddButton().paddingOnly(left: 10), mainAxisAlignment: MainAxisAlignment.center,
pageViewBuilder: (pageView) => pageView, children: [
labelGetter: DesktopTab.tablabelGetter, icon,
tabBuilder: (key, icon, label, themeConf) => Obx(() { label,
final connectionType = ConnectionTypeState.find(key); ],
if (!connectionType.isValid()) { );
return Row( } else {
mainAxisAlignment: MainAxisAlignment.center, bool secure =
children: [ connectionType.secure.value == ConnectionType.strSecure;
icon, bool direct =
label, connectionType.direct.value == ConnectionType.strDirect;
], String msgConn;
); if (secure && direct) {
} else { msgConn = translate("Direct and encrypted connection");
bool secure = } else if (secure && !direct) {
connectionType.secure.value == ConnectionType.strSecure; msgConn = translate("Relayed and encrypted connection");
bool direct = } else if (!secure && direct) {
connectionType.direct.value == ConnectionType.strDirect; msgConn = translate("Direct and unencrypted connection");
String msgConn; } else {
if (secure && direct) { msgConn = translate("Relayed and unencrypted connection");
msgConn = translate("Direct and encrypted connection"); }
} else if (secure && !direct) { var msgFingerprint = '${translate('Fingerprint')}:\n';
msgConn = translate("Relayed and encrypted connection"); var fingerprint = FingerprintState.find(key).value;
} else if (!secure && direct) { if (fingerprint.isEmpty) {
msgConn = translate("Direct and unencrypted connection"); fingerprint = 'N/A';
} else { }
msgConn = translate("Relayed and unencrypted connection"); if (fingerprint.length > 5 * 8) {
} var first = fingerprint.substring(0, 39);
var msgFingerprint = '${translate('Fingerprint')}:\n'; var second = fingerprint.substring(40);
var fingerprint = FingerprintState.find(key).value; msgFingerprint += '$first\n$second';
if (fingerprint.isEmpty) { } else {
fingerprint = 'N/A'; msgFingerprint += fingerprint;
} }
if (fingerprint.length > 5 * 8) {
var first = fingerprint.substring(0, 39);
var second = fingerprint.substring(40);
msgFingerprint += '$first\n$second';
} else {
msgFingerprint += fingerprint;
}
final tab = Row( final tab = Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
icon, icon,
Tooltip( Tooltip(
message: '$msgConn\n$msgFingerprint', message: '$msgConn\n$msgFingerprint',
child: SvgPicture.asset( child: SvgPicture.asset(
'assets/${connectionType.secure.value}${connectionType.direct.value}.svg', 'assets/${connectionType.secure.value}${connectionType.direct.value}.svg',
width: themeConf.iconSize, width: themeConf.iconSize,
height: themeConf.iconSize, height: themeConf.iconSize,
).paddingOnly(right: 5), ).paddingOnly(right: 5),
), ),
label, label,
unreadMessageCountBuilder(UnreadChatCountState.find(key)) unreadMessageCountBuilder(UnreadChatCountState.find(key))
.marginOnly(left: 4), .marginOnly(left: 4),
], ],
); );
return Listener( return Listener(
onPointerDown: (e) { onPointerDown: (e) {
if (e.kind != ui.PointerDeviceKind.mouse) { if (e.kind != ui.PointerDeviceKind.mouse) {
return; return;
} }
final remotePage = tabController.state.value.tabs final remotePage = tabController.state.value.tabs
.firstWhere((tab) => tab.key == key) .firstWhere((tab) => tab.key == key)
.page as RemotePage; .page as RemotePage;
if (remotePage.ffi.ffiModel.pi.isSet.isTrue && if (remotePage.ffi.ffiModel.pi.isSet.isTrue && e.buttons == 2) {
e.buttons == 2) { showRightMenu(
showRightMenu( (CancelFunc cancelFunc) {
(CancelFunc cancelFunc) { return _tabMenuBuilder(key, cancelFunc);
return _tabMenuBuilder(key, cancelFunc); },
}, target: e.position,
target: e.position, );
); }
} },
}, child: tab,
child: tab, );
); }
} }),
}),
),
),
), ),
); );
return Platform.isMacOS || kUseCompatibleUiMode final tabWidget = isLinux
? buildVirtualWindowFrame(context, child)
: Obx(() => Container(
decoration: BoxDecoration(
border: Border.all(
color: MyTheme.color(context).border!,
width: stateGlobal.windowBorderWidth.value),
),
child: child,
));
return isMacOS || kUseCompatibleUiMode
? tabWidget ? tabWidget
: Obx(() => SubWindowDragToResizeArea( : Obx(() => SubWindowDragToResizeArea(
key: contentKey, key: contentKey,
@@ -498,4 +400,130 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
_update_remote_count() => _update_remote_count() =>
RemoteCountState.find().value = tabController.length; RemoteCountState.find().value = tabController.length;
Future<dynamic> _remoteMethodHandler(call, fromWindowId) async {
print(
"[Remote Page] call ${call.method} with args ${call.arguments} from window $fromWindowId");
dynamic returnValue;
// for simplify, just replace connectionId
if (call.method == kWindowEventNewRemoteDesktop) {
final args = jsonDecode(call.arguments);
final id = args['id'];
final switchUuid = args['switch_uuid'];
final sessionId = args['session_id'];
final tabWindowId = args['tab_window_id'];
final display = args['display'];
final displays = args['displays'];
final screenRect = parseParamScreenRect(args);
windowOnTop(windowId());
tryMoveToScreenAndSetFullscreen(screenRect);
if (tabController.length == 0) {
// Show the hidden window.
if (isMacOS && stateGlobal.closeOnFullscreen == true) {
stateGlobal.setFullscreen(true);
}
// Reset the state
stateGlobal.closeOnFullscreen = null;
}
ConnectionTypeState.init(id);
_toolbarState.setShow(
bind.mainGetUserDefaultOption(key: 'collapse_toolbar') != 'Y');
tabController.add(TabInfo(
key: id,
label: id,
selectedIcon: selectedIcon,
unselectedIcon: unselectedIcon,
onTabCloseButton: () => tabController.closeBy(id),
page: RemotePage(
key: ValueKey(id),
id: id,
sessionId: sessionId == null ? null : SessionID(sessionId),
tabWindowId: tabWindowId,
display: display,
displays: displays?.cast<int>(),
password: args['password'],
toolbarState: _toolbarState,
tabController: tabController,
switchUuid: switchUuid,
forceRelay: args['forceRelay'],
isSharedPassword: args['isSharedPassword'],
),
));
} else if (call.method == kWindowDisableGrabKeyboard) {
// ???
} else if (call.method == "onDestroy") {
tabController.clear();
} else if (call.method == kWindowActionRebuild) {
reloadCurrentWindow();
} else if (call.method == kWindowEventActiveSession) {
final jumpOk = tabController.jumpToByKey(call.arguments);
if (jumpOk) {
windowOnTop(windowId());
}
return jumpOk;
} else if (call.method == kWindowEventActiveDisplaySession) {
final args = jsonDecode(call.arguments);
final id = args['id'];
final display = args['display'];
final jumpOk = tabController.jumpToByKeyAndDisplay(id, display);
if (jumpOk) {
windowOnTop(windowId());
}
return jumpOk;
} else if (call.method == kWindowEventGetRemoteList) {
return tabController.state.value.tabs
.map((e) => e.key)
.toList()
.join(',');
} else if (call.method == kWindowEventGetSessionIdList) {
return tabController.state.value.tabs
.map((e) => '${e.key},${(e.page as RemotePage).ffi.sessionId}')
.toList()
.join(';');
} else if (call.method == kWindowEventGetCachedSessionData) {
// Ready to show new window and close old tab.
final args = jsonDecode(call.arguments);
final id = args['id'];
final close = args['close'];
try {
final remotePage = tabController.state.value.tabs
.firstWhere((tab) => tab.key == id)
.page as RemotePage;
returnValue = remotePage.ffi.ffiModel.cachedPeerData.toString();
} catch (e) {
debugPrint('Failed to get cached session data: $e');
}
if (close && returnValue != null) {
closeSessionOnDispose[id] = false;
tabController.closeBy(id);
}
} else if (call.method == kWindowEventRemoteWindowCoords) {
final remotePage =
tabController.state.value.selectedTabInfo.page as RemotePage;
final ffi = remotePage.ffi;
final displayRect = ffi.ffiModel.displaysRect();
if (displayRect != null) {
final wc = WindowController.fromWindowId(windowId());
Rect? frame;
try {
frame = await wc.getFrame();
} catch (e) {
debugPrint(
"Failed to get frame of window $windowId, it may be hidden");
}
if (frame != null) {
ffi.cursorModel.moveLocal(0, 0);
final coords = RemoteWindowCoords(
frame,
CanvasCoords.fromCanvasModel(ffi.canvasModel),
CursorCoords.fromCursorModel(ffi.cursorModel),
displayRect);
returnValue = jsonEncode(coords.toJson());
}
}
}
_update_remote_count();
return returnValue;
}
} }

View File

@@ -1,10 +1,10 @@
// original cm window in Sciter version. // original cm window in Sciter version.
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common/widgets/audio_input.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart'; import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/models/chat_model.dart'; import 'package:flutter_hbb/models/chat_model.dart';
@@ -52,7 +52,7 @@ class _DesktopServerPageState extends State<DesktopServerPage>
@override @override
void onWindowClose() { void onWindowClose() {
Future.wait([gFFI.serverModel.closeAll(), gFFI.close()]).then((_) { Future.wait([gFFI.serverModel.closeAll(), gFFI.close()]).then((_) {
if (Platform.isMacOS) { if (isMacOS) {
RdPlatformChannel.instance.terminate(); RdPlatformChannel.instance.terminate();
} else { } else {
windowManager.setPreventClose(false); windowManager.setPreventClose(false);
@@ -77,14 +77,20 @@ class _DesktopServerPageState extends State<DesktopServerPage>
ChangeNotifierProvider.value(value: gFFI.chatModel), ChangeNotifierProvider.value(value: gFFI.chatModel),
], ],
child: Consumer<ServerModel>( child: Consumer<ServerModel>(
builder: (context, serverModel, child) => Container( builder: (context, serverModel, child) {
decoration: BoxDecoration( final body = Scaffold(
border: Border.all(color: MyTheme.color(context).border!)),
child: Scaffold(
backgroundColor: Theme.of(context).scaffoldBackgroundColor, backgroundColor: Theme.of(context).scaffoldBackgroundColor,
body: ConnectionManager(), body: ConnectionManager(),
), );
), return isLinux
? buildVirtualWindowFrame(context, body)
: Container(
decoration: BoxDecoration(
border:
Border.all(color: MyTheme.color(context).border!)),
child: body,
);
},
), ),
); );
} }
@@ -158,7 +164,7 @@ class ConnectionManagerState extends State<ConnectionManager> {
controller: serverModel.tabController, controller: serverModel.tabController,
selectedBorderColor: MyTheme.accent, selectedBorderColor: MyTheme.accent,
maxLabelWidth: 100, maxLabelWidth: 100,
tail: buildScrollJumper(), tail: null, //buildScrollJumper(),
selectedTabBackgroundColor: selectedTabBackgroundColor:
Theme.of(context).hintColor.withOpacity(0), Theme.of(context).hintColor.withOpacity(0),
tabBuilder: (key, icon, label, themeConf) { tabBuilder: (key, icon, label, themeConf) {
@@ -327,11 +333,7 @@ class _AppIcon extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
margin: EdgeInsets.symmetric(horizontal: 4.0), margin: EdgeInsets.symmetric(horizontal: 4.0),
child: SvgPicture.asset( child: loadIcon(30),
'assets/logo.svg',
width: 30,
height: 30,
),
); );
} }
} }
@@ -655,7 +657,7 @@ class _PrivilegeBoardState extends State<_PrivilegeBoard> {
translate('Enable recording session'), translate('Enable recording session'),
), ),
// only windows support block input // only windows support block input
if (Platform.isWindows) if (isWindows)
buildPermissionIcon( buildPermissionIcon(
client.blockInput, client.blockInput,
Icons.block, Icons.block,
@@ -706,17 +708,86 @@ class _CmControlPanel extends StatelessWidget {
children: [ children: [
Offstage( Offstage(
offstage: !client.inVoiceCall, offstage: !client.inVoiceCall,
child: buildButton( child: Row(
context, children: [
color: Colors.red, Expanded(
onClick: () => closeVoiceCall(), child: buildButton(context,
icon: Icon( color: MyTheme.accent,
Icons.call_end_rounded, onClick: null, onTapDown: (details) async {
color: Colors.white, final devicesInfo = await AudioInput.getDevicesInfo();
size: 14, List<String> devices = devicesInfo['devices'] as List<String>;
), if (devices.isEmpty) {
text: "Stop voice call", msgBox(
textColor: Colors.white, gFFI.sessionId,
'custom-nocancel-info',
'Prompt',
'no_audio_input_device_tip',
'',
gFFI.dialogManager,
);
return;
}
String currentDevice = devicesInfo['current'] as String;
final x = details.globalPosition.dx;
final y = details.globalPosition.dy;
final position = RelativeRect.fromLTRB(x, y, x, y);
showMenu(
context: context,
position: position,
items: devices
.map((d) => PopupMenuItem<String>(
value: d,
height: 18,
padding: EdgeInsets.zero,
onTap: () => AudioInput.setDevice(d),
child: IgnorePointer(
child: RadioMenuButton(
value: d,
groupValue: currentDevice,
onChanged: (v) {
if (v != null) AudioInput.setDevice(v);
},
child: Container(
child: Text(
d,
overflow: TextOverflow.ellipsis,
maxLines: 1,
),
constraints: BoxConstraints(
maxWidth:
kConnectionManagerWindowSizeClosedChat
.width -
80),
),
)),
))
.toList(),
);
},
icon: Icon(
Icons.call_rounded,
color: Colors.white,
size: 14,
),
text: "Audio input",
textColor: Colors.white),
),
Expanded(
child: buildButton(
context,
color: Colors.red,
onClick: () => closeVoiceCall(),
icon: Icon(
Icons.call_end_rounded,
color: Colors.white,
size: 14,
),
text: "Stop voice call",
textColor: Colors.white,
),
)
],
), ),
), ),
Offstage( Offstage(
@@ -877,12 +948,14 @@ class _CmControlPanel extends StatelessWidget {
Widget buildButton(BuildContext context, Widget buildButton(BuildContext context,
{required Color? color, {required Color? color,
required Function() onClick, GestureTapCallback? onClick,
Icon? icon, Widget? icon,
BoxBorder? border, BoxBorder? border,
required String text, required String text,
required Color? textColor, required Color? textColor,
String? tooltip}) { String? tooltip,
GestureTapDownCallback? onTapDown}) {
assert(!(onClick == null && onTapDown == null));
Widget textWidget; Widget textWidget;
if (icon != null) { if (icon != null) {
textWidget = Text( textWidget = Text(
@@ -906,7 +979,16 @@ class _CmControlPanel extends StatelessWidget {
color: color, borderRadius: borderRadius, border: border), color: color, borderRadius: borderRadius, border: border),
child: InkWell( child: InkWell(
borderRadius: borderRadius, borderRadius: borderRadius,
onTap: () => checkClickTime(client.id, onClick), onTap: () {
if (onClick == null) return;
checkClickTime(client.id, onClick);
},
onTapDown: (details) {
if (onTapDown == null) return;
checkClickTime(client.id, () {
onTapDown.call(details);
});
},
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [

View File

@@ -20,6 +20,7 @@ class DesktopFileTransferScreen extends StatelessWidget {
ChangeNotifierProvider.value(value: gFFI.canvasModel), ChangeNotifierProvider.value(value: gFFI.canvasModel),
], ],
child: Scaffold( child: Scaffold(
backgroundColor: isLinux ? Colors.transparent : null,
body: FileManagerTabPage( body: FileManagerTabPage(
params: params, params: params,
), ),

View File

@@ -17,6 +17,7 @@ class DesktopPortForwardScreen extends StatelessWidget {
ChangeNotifierProvider.value(value: gFFI.ffiModel), ChangeNotifierProvider.value(value: gFFI.ffiModel),
], ],
child: Scaffold( child: Scaffold(
backgroundColor: isLinux ? Colors.transparent : null,
body: PortForwardTabPage( body: PortForwardTabPage(
params: params, params: params,
), ),

View File

@@ -1,5 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
import 'package:flutter_hbb/desktop/pages/remote_tab_page.dart'; import 'package:flutter_hbb/desktop/pages/remote_tab_page.dart';
@@ -28,7 +26,7 @@ class DesktopRemoteScreen extends StatelessWidget {
child: Scaffold( child: Scaffold(
// Set transparent background for padding the resize area out of the flutter view. // Set transparent background for padding the resize area out of the flutter view.
// This allows the wallpaper goes through our resize area. (Linux only now). // This allows the wallpaper goes through our resize area. (Linux only now).
backgroundColor: Platform.isLinux ? Colors.transparent : null, backgroundColor: isLinux ? Colors.transparent : null,
body: ConnectionTabPage( body: ConnectionTabPage(
params: params, params: params,
), ),

View File

@@ -1,4 +1,3 @@
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
@@ -175,9 +174,9 @@ String getLocalPlatformForKBLayoutType(String peerPlatform) {
return localPlatform; return localPlatform;
} }
if (Platform.isWindows) { if (isWindows) {
localPlatform = kPeerPlatformWindows; localPlatform = kPeerPlatformWindows;
} else if (Platform.isLinux) { } else if (isLinux) {
localPlatform = kPeerPlatformLinux; localPlatform = kPeerPlatformLinux;
} }
// to-do: web desktop support ? // to-do: web desktop support ?

View File

@@ -568,6 +568,47 @@ class MenuEntrySwitch<T> extends MenuEntrySwitchBase<T> {
} }
} }
// Compatible with MenuEntrySwitch, it uses value instead of getter
class MenuEntrySwitchSync<T> extends MenuEntrySwitchBase<T> {
final SwitchSetter setter;
final RxBool _curOption = false.obs;
MenuEntrySwitchSync({
required SwitchType switchType,
required String text,
required bool currentValue,
required this.setter,
Rx<TextStyle>? textStyle,
EdgeInsets? padding,
dismissOnClicked = false,
RxBool? enabled,
dismissCallback,
}) : super(
switchType: switchType,
text: text,
textStyle: textStyle,
padding: padding,
dismissOnClicked: dismissOnClicked,
enabled: enabled,
dismissCallback: dismissCallback,
) {
_curOption.value = currentValue;
}
@override
RxBool get curOption => _curOption;
@override
setOption(bool? option) async {
if (option != null) {
await setter(option);
// Notice: no ensure with getter, best used on menus that are destroyed on click
if (_curOption.value != option) {
_curOption.value = option;
}
}
}
}
typedef Switch2Getter = RxBool Function(); typedef Switch2Getter = RxBool Function();
typedef Switch2Setter = Future<void> Function(bool); typedef Switch2Setter = Future<void> Function(bool);

View File

@@ -1,9 +1,9 @@
import 'dart:convert'; import 'dart:convert';
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_hbb/common/widgets/audio_input.dart';
import 'package:flutter_hbb/common/widgets/toolbar.dart'; import 'package:flutter_hbb/common/widgets/toolbar.dart';
import 'package:flutter_hbb/models/chat_model.dart'; import 'package:flutter_hbb/models/chat_model.dart';
import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/models/state_model.dart';
@@ -112,10 +112,10 @@ class _ToolbarTheme {
static const double iconRadius = 8; static const double iconRadius = 8;
static const double elevation = 3; static const double elevation = 3;
static double dividerSpaceToAction = Platform.isWindows ? 8 : 14; static double dividerSpaceToAction = isWindows ? 8 : 14;
static double menuBorderRadius = Platform.isWindows ? 5.0 : 7.0; static double menuBorderRadius = isWindows ? 5.0 : 7.0;
static EdgeInsets menuPadding = Platform.isWindows static EdgeInsets menuPadding = isWindows
? EdgeInsets.fromLTRB(4, 12, 4, 12) ? EdgeInsets.fromLTRB(4, 12, 4, 12)
: EdgeInsets.fromLTRB(6, 14, 6, 14); : EdgeInsets.fromLTRB(6, 14, 6, 14);
static const double menuButtonBorderRadius = 3.0; static const double menuButtonBorderRadius = 3.0;
@@ -492,7 +492,7 @@ class _RemoteToolbarState extends State<RemoteToolbar> {
toolbarItems.add(_ChatMenu(id: widget.id, ffi: widget.ffi)); toolbarItems.add(_ChatMenu(id: widget.id, ffi: widget.ffi));
toolbarItems.add(_VoiceCallMenu(id: widget.id, ffi: widget.ffi)); toolbarItems.add(_VoiceCallMenu(id: widget.id, ffi: widget.ffi));
} }
toolbarItems.add(_RecordMenu()); if (!isWeb) toolbarItems.add(_RecordMenu());
toolbarItems.add(_CloseMenu(id: widget.id, ffi: widget.ffi)); toolbarItems.add(_CloseMenu(id: widget.id, ffi: widget.ffi));
final toolbarBorderRadius = BorderRadius.all(Radius.circular(4.0)); final toolbarBorderRadius = BorderRadius.all(Radius.circular(4.0));
return Column( return Column(
@@ -637,7 +637,7 @@ class _MonitorMenu extends StatelessWidget {
menuStyle: MenuStyle( menuStyle: MenuStyle(
padding: padding:
MaterialStatePropertyAll(EdgeInsets.symmetric(horizontal: 6))), MaterialStatePropertyAll(EdgeInsets.symmetric(horizontal: 6))),
menuChildren: [buildMonitorSubmenuWidget()]); menuChildrenGetter: () => [buildMonitorSubmenuWidget()]);
} }
Widget buildMultiMonitorMenu() { Widget buildMultiMonitorMenu() {
@@ -759,15 +759,18 @@ class _MonitorMenu extends StatelessWidget {
final children = <Widget>[]; final children = <Widget>[];
for (var i = 0; i < pi.displays.length; i++) { for (var i = 0; i < pi.displays.length; i++) {
final d = pi.displays[i]; final d = pi.displays[i];
final fontSize = (d.width * scale < d.height * scale double s = d.scale;
? d.width * scale int dWidth = d.width.toDouble() ~/ s;
: d.height * scale) * int dHeight = d.height.toDouble() ~/ s;
final fontSize = (dWidth * scale < dHeight * scale
? dWidth * scale
: dHeight * scale) *
0.65; 0.65;
children.add(Positioned( children.add(Positioned(
left: (d.x - rect.left) * scale + startX, left: (d.x - rect.left) * scale + startX,
top: (d.y - rect.top) * scale + startY, top: (d.y - rect.top) * scale + startY,
width: d.width * scale, width: dWidth * scale,
height: d.height * scale, height: dHeight * scale,
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
@@ -841,17 +844,17 @@ class _ControlMenu extends StatelessWidget {
color: _ToolbarTheme.blueColor, color: _ToolbarTheme.blueColor,
hoverColor: _ToolbarTheme.hoverBlueColor, hoverColor: _ToolbarTheme.hoverBlueColor,
ffi: ffi, ffi: ffi,
menuChildren: toolbarControls(context, id, ffi).map((e) { menuChildrenGetter: () => toolbarControls(context, id, ffi).map((e) {
if (e.divider) { if (e.divider) {
return Divider(); return Divider();
} else { } else {
return MenuButton( return MenuButton(
child: e.child, child: e.child,
onPressed: e.onPressed, onPressed: e.onPressed,
ffi: ffi, ffi: ffi,
trailingIcon: e.trailingIcon); trailingIcon: e.trailingIcon);
} }
}).toList()); }).toList());
} }
} }
@@ -938,13 +941,12 @@ class ScreenAdjustor {
} }
updateScreen() async { updateScreen() async {
final v = await rustDeskWinManager.call( final String info =
WindowType.Main, kWindowGetWindowInfo, ''); isWeb ? screenInfo : await _getScreenInfoDesktop() ?? '';
final String valueStr = v.result; if (info.isEmpty) {
if (valueStr.isEmpty) {
_screen = null; _screen = null;
} else { } else {
final screenMap = jsonDecode(valueStr); final screenMap = jsonDecode(info);
_screen = window_size.Screen( _screen = window_size.Screen(
Rect.fromLTRB(screenMap['frame']['l'], screenMap['frame']['t'], Rect.fromLTRB(screenMap['frame']['l'], screenMap['frame']['t'],
screenMap['frame']['r'], screenMap['frame']['b']), screenMap['frame']['r'], screenMap['frame']['b']),
@@ -957,15 +959,23 @@ class ScreenAdjustor {
} }
} }
_getScreenInfoDesktop() async {
final v = await rustDeskWinManager.call(
WindowType.Main, kWindowGetWindowInfo, '');
return v.result;
}
Future<bool> isWindowCanBeAdjusted() async { Future<bool> isWindowCanBeAdjusted() async {
final viewStyle = final viewStyle =
await bind.sessionGetViewStyle(sessionId: ffi.sessionId) ?? ''; await bind.sessionGetViewStyle(sessionId: ffi.sessionId) ?? '';
if (viewStyle != kRemoteViewStyleOriginal) { if (viewStyle != kRemoteViewStyleOriginal) {
return false; return false;
} }
final remoteCount = RemoteCountState.find().value; if (!isWeb) {
if (remoteCount != 1) { final remoteCount = RemoteCountState.find().value;
return false; if (remoteCount != 1) {
return false;
}
} }
if (_screen == null) { if (_screen == null) {
return false; return false;
@@ -1036,54 +1046,63 @@ class _DisplayMenuState extends State<_DisplayMenu> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
_screenAdjustor.updateScreen(); _screenAdjustor.updateScreen();
menuChildrenGetter() {
final menuChildren = <Widget>[ final menuChildren = <Widget>[
_screenAdjustor.adjustWindow(context), _screenAdjustor.adjustWindow(context),
viewStyle(), viewStyle(),
scrollStyle(), scrollStyle(),
imageQuality(), imageQuality(),
codec(), codec(),
_ResolutionsMenu( _ResolutionsMenu(
id: widget.id, id: widget.id,
ffi: widget.ffi, ffi: widget.ffi,
screenAdjustor: _screenAdjustor, screenAdjustor: _screenAdjustor,
), ),
// We may add this feature if it is needed and we have an EV certificate. if (pi.isRustDeskIdd)
// _VirtualDisplayMenu( _RustDeskVirtualDisplayMenu(
// id: widget.id, id: widget.id,
// ffi: widget.ffi, ffi: widget.ffi,
// ), ),
Divider(), if (pi.isAmyuniIdd)
toggles(), _AmyuniVirtualDisplayMenu(
]; id: widget.id,
// privacy mode ffi: widget.ffi,
if (ffiModel.keyboard && pi.features.privacyMode) { ),
final privacyModeState = PrivacyModeState.find(id); Divider(),
final privacyModeList = cursorToggles(),
toolbarPrivacyMode(privacyModeState, context, id, ffi); Divider(),
if (privacyModeList.length == 1) { toggles(),
menuChildren.add(CkbMenuButton( ];
value: privacyModeList[0].value, // privacy mode
onChanged: privacyModeList[0].onChanged, if (ffiModel.keyboard && pi.features.privacyMode) {
child: privacyModeList[0].child, final privacyModeState = PrivacyModeState.find(id);
ffi: ffi)); final privacyModeList =
} else if (privacyModeList.length > 1) { toolbarPrivacyMode(privacyModeState, context, id, ffi);
menuChildren.addAll([ if (privacyModeList.length == 1) {
Divider(), menuChildren.add(CkbMenuButton(
_SubmenuButton( value: privacyModeList[0].value,
ffi: widget.ffi, onChanged: privacyModeList[0].onChanged,
child: Text(translate('Privacy mode')), child: privacyModeList[0].child,
menuChildren: privacyModeList ffi: ffi));
.map((e) => CkbMenuButton( } else if (privacyModeList.length > 1) {
value: e.value, menuChildren.addAll([
onChanged: e.onChanged, Divider(),
child: e.child, _SubmenuButton(
ffi: ffi)) ffi: widget.ffi,
.toList()), child: Text(translate('Privacy mode')),
]); menuChildren: privacyModeList
.map((e) => CkbMenuButton(
value: e.value,
onChanged: e.onChanged,
child: e.child,
ffi: ffi))
.toList()),
]);
}
} }
menuChildren.add(widget.pluginItem);
return menuChildren;
} }
menuChildren.add(widget.pluginItem);
return _IconSubmenuButton( return _IconSubmenuButton(
tooltip: 'Display Settings', tooltip: 'Display Settings',
@@ -1091,7 +1110,7 @@ class _DisplayMenuState extends State<_DisplayMenu> {
ffi: widget.ffi, ffi: widget.ffi,
color: _ToolbarTheme.blueColor, color: _ToolbarTheme.blueColor,
hoverColor: _ToolbarTheme.hoverBlueColor, hoverColor: _ToolbarTheme.hoverBlueColor,
menuChildren: menuChildren, menuChildrenGetter: menuChildrenGetter,
); );
} }
@@ -1195,6 +1214,23 @@ class _DisplayMenuState extends State<_DisplayMenu> {
}); });
} }
cursorToggles() {
return futureBuilder(
future: toolbarCursor(context, id, ffi),
hasData: (data) {
final v = data as List<TToggleMenu>;
if (v.isEmpty) return Offstage();
return Column(
children: v
.map((e) => CkbMenuButton(
value: e.value,
onChanged: e.onChanged,
child: e.child,
ffi: ffi))
.toList());
});
}
toggles() { toggles() {
return futureBuilder( return futureBuilder(
future: toolbarDisplayToggle(context, id, ffi), future: toolbarDisplayToggle(context, id, ffi),
@@ -1244,7 +1280,7 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
FFI get ffi => widget.ffi; FFI get ffi => widget.ffi;
PeerInfo get pi => widget.ffi.ffiModel.pi; PeerInfo get pi => widget.ffi.ffiModel.pi;
FfiModel get ffiModel => widget.ffi.ffiModel; FfiModel get ffiModel => widget.ffi.ffiModel;
Rect? get rect => ffiModel.rect; Rect? get rect => scaledRect();
List<Resolution> get resolutions => pi.resolutions; List<Resolution> get resolutions => pi.resolutions;
bool get isWayland => bind.mainCurrentIsWayland(); bool get isWayland => bind.mainCurrentIsWayland();
@@ -1254,6 +1290,20 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
_getLocalResolutionWayland(); _getLocalResolutionWayland();
} }
Rect? scaledRect() {
final scale = pi.scaleOfDisplay(pi.currentDisplay);
final rect = ffiModel.rect;
if (rect == null) {
return null;
}
return Rect.fromLTWH(
rect.left,
rect.top,
rect.width / scale,
rect.height / scale,
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isVirtualDisplay = ffiModel.isVirtualDisplayResolution; final isVirtualDisplay = ffiModel.isVirtualDisplayResolution;
@@ -1287,7 +1337,8 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
if (lastGroupValue == _kCustomResolutionValue) { if (lastGroupValue == _kCustomResolutionValue) {
_groupValue = _kCustomResolutionValue; _groupValue = _kCustomResolutionValue;
} else { } else {
_groupValue = '${rect?.width.toInt()}x${rect?.height.toInt()}'; _groupValue =
'${(rect?.width ?? 0).toInt()}x${(rect?.height ?? 0).toInt()}';
} }
} }
@@ -1321,6 +1372,14 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
final display = json.decode(mainDisplay); final display = json.decode(mainDisplay);
if (display['w'] != null && display['h'] != null) { if (display['w'] != null && display['h'] != null) {
_localResolution = Resolution(display['w'], display['h']); _localResolution = Resolution(display['w'], display['h']);
if (isWeb) {
if (display['scaleFactor'] != null) {
_localResolution = Resolution(
(display['w'] / display['scaleFactor']).toInt(),
(display['h'] / display['scaleFactor']).toInt(),
);
}
}
} }
} catch (e) { } catch (e) {
debugPrint('Failed to decode $mainDisplay, $e'); debugPrint('Failed to decode $mainDisplay, $e');
@@ -1386,6 +1445,11 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
if (display == null) { if (display == null) {
return Offstage(); return Offstage();
} }
if (!resolutions.any((e) =>
e.width == display.originalWidth &&
e.height == display.originalHeight)) {
return Offstage();
}
return Offstage( return Offstage(
offstage: !showOriginalBtn, offstage: !showOriginalBtn,
child: MenuButton( child: MenuButton(
@@ -1500,21 +1564,23 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
} }
} }
class _VirtualDisplayMenu extends StatefulWidget { class _RustDeskVirtualDisplayMenu extends StatefulWidget {
final String id; final String id;
final FFI ffi; final FFI ffi;
_VirtualDisplayMenu({ _RustDeskVirtualDisplayMenu({
Key? key, Key? key,
required this.id, required this.id,
required this.ffi, required this.ffi,
}) : super(key: key); }) : super(key: key);
@override @override
State<_VirtualDisplayMenu> createState() => _VirtualDisplayMenuState(); State<_RustDeskVirtualDisplayMenu> createState() =>
_RustDeskVirtualDisplayMenuState();
} }
class _VirtualDisplayMenuState extends State<_VirtualDisplayMenu> { class _RustDeskVirtualDisplayMenuState
extends State<_RustDeskVirtualDisplayMenu> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@@ -1529,7 +1595,7 @@ class _VirtualDisplayMenuState extends State<_VirtualDisplayMenu> {
return Offstage(); return Offstage();
} }
final virtualDisplays = widget.ffi.ffiModel.pi.virtualDisplays; final virtualDisplays = widget.ffi.ffiModel.pi.RustDeskVirtualDisplays;
final privacyModeState = PrivacyModeState.find(widget.id); final privacyModeState = PrivacyModeState.find(widget.id);
final children = <Widget>[]; final children = <Widget>[];
@@ -1571,6 +1637,82 @@ class _VirtualDisplayMenuState extends State<_VirtualDisplayMenu> {
} }
} }
class _AmyuniVirtualDisplayMenu extends StatefulWidget {
final String id;
final FFI ffi;
_AmyuniVirtualDisplayMenu({
Key? key,
required this.id,
required this.ffi,
}) : super(key: key);
@override
State<_AmyuniVirtualDisplayMenu> createState() =>
_AmiyuniVirtualDisplayMenuState();
}
class _AmiyuniVirtualDisplayMenuState extends State<_AmyuniVirtualDisplayMenu> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
if (widget.ffi.ffiModel.pi.platform != kPeerPlatformWindows) {
return Offstage();
}
if (!widget.ffi.ffiModel.pi.isInstalled) {
return Offstage();
}
final count = widget.ffi.ffiModel.pi.amyuniVirtualDisplayCount;
final privacyModeState = PrivacyModeState.find(widget.id);
final children = <Widget>[
Obx(() => Row(
children: [
TextButton(
onPressed: privacyModeState.isNotEmpty || count == 0
? null
: () => bind.sessionToggleVirtualDisplay(
sessionId: widget.ffi.sessionId, index: 0, on: false),
child: Icon(Icons.remove),
),
Text(count.toString()),
TextButton(
onPressed: privacyModeState.isNotEmpty || count == 4
? null
: () => bind.sessionToggleVirtualDisplay(
sessionId: widget.ffi.sessionId, index: 0, on: true),
child: Icon(Icons.add),
),
],
)),
Divider(),
Obx(() => MenuButton(
onPressed: privacyModeState.isNotEmpty || count == 0
? null
: () {
bind.sessionToggleVirtualDisplay(
sessionId: widget.ffi.sessionId,
index: kAllVirtualDisplay,
on: false);
},
ffi: widget.ffi,
child: Text(translate('Plug out all')),
)),
];
return _SubmenuButton(
ffi: widget.ffi,
menuChildren: children,
child: Text(translate("Virtual display")),
);
}
}
class _KeyboardMenu extends StatelessWidget { class _KeyboardMenu extends StatelessWidget {
final String id; final String id;
final FFI ffi; final FFI ffi;
@@ -1586,19 +1728,7 @@ class _KeyboardMenu extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var ffiModel = Provider.of<FfiModel>(context); var ffiModel = Provider.of<FfiModel>(context);
if (!ffiModel.keyboard) return Offstage(); if (!ffiModel.keyboard) return Offstage();
// If use flutter to grab keys, we can only use one mode. toolbarToggles() => toolbarKeyboardToggles(ffi)
// Map mode and Legacy mode, at least one of them is supported.
String? modeOnly;
if (isInputSourceFlutter) {
if (bind.sessionIsKeyboardModeSupported(
sessionId: ffi.sessionId, mode: kKeyMapMode)) {
modeOnly = kKeyMapMode;
} else if (bind.sessionIsKeyboardModeSupported(
sessionId: ffi.sessionId, mode: kKeyLegacyMode)) {
modeOnly = kKeyLegacyMode;
}
}
final toolbarToggles = toolbarKeyboardToggles(ffi)
.map((e) => CkbMenuButton( .map((e) => CkbMenuButton(
value: e.value, onChanged: e.onChanged, child: e.child, ffi: ffi)) value: e.value, onChanged: e.onChanged, child: e.child, ffi: ffi))
.toList(); .toList();
@@ -1608,18 +1738,18 @@ class _KeyboardMenu extends StatelessWidget {
ffi: ffi, ffi: ffi,
color: _ToolbarTheme.blueColor, color: _ToolbarTheme.blueColor,
hoverColor: _ToolbarTheme.hoverBlueColor, hoverColor: _ToolbarTheme.hoverBlueColor,
menuChildren: [ menuChildrenGetter: () => [
keyboardMode(modeOnly), keyboardMode(),
localKeyboardType(), localKeyboardType(),
inputSource(), inputSource(),
Divider(), Divider(),
viewMode(), viewMode(),
Divider(), Divider(),
...toolbarToggles, ...toolbarToggles(),
]); ]);
} }
keyboardMode(String? modeOnly) { keyboardMode() {
return futureBuilder(future: () async { return futureBuilder(future: () async {
return await bind.sessionGetKeyboardMode(sessionId: ffi.sessionId) ?? return await bind.sessionGetKeyboardMode(sessionId: ffi.sessionId) ??
kKeyLegacyMode; kKeyLegacyMode;
@@ -1639,6 +1769,19 @@ class _KeyboardMenu extends StatelessWidget {
await ffi.inputModel.updateKeyboardMode(); await ffi.inputModel.updateKeyboardMode();
} }
// If use flutter to grab keys, we can only use one mode.
// Map mode and Legacy mode, at least one of them is supported.
String? modeOnly;
if (isInputSourceFlutter) {
if (bind.sessionIsKeyboardModeSupported(
sessionId: ffi.sessionId, mode: kKeyMapMode)) {
modeOnly = kKeyMapMode;
} else if (bind.sessionIsKeyboardModeSupported(
sessionId: ffi.sessionId, mode: kKeyLegacyMode)) {
modeOnly = kKeyLegacyMode;
}
}
for (InputModeMenu mode in modes) { for (InputModeMenu mode in modes) {
if (modeOnly != null && mode.key != modeOnly) { if (modeOnly != null && mode.key != modeOnly) {
continue; continue;
@@ -1732,7 +1875,7 @@ class _KeyboardMenu extends StatelessWidget {
? (value) async { ? (value) async {
if (value == null) return; if (value == null) return;
await bind.sessionToggleOption( await bind.sessionToggleOption(
sessionId: ffi.sessionId, value: 'view-only'); sessionId: ffi.sessionId, value: kOptionViewOnly);
ffiModel.setViewOnly(id, value); ffiModel.setViewOnly(id, value);
} }
: null, : null,
@@ -1767,7 +1910,7 @@ class _ChatMenuState extends State<_ChatMenu> {
ffi: widget.ffi, ffi: widget.ffi,
color: _ToolbarTheme.blueColor, color: _ToolbarTheme.blueColor,
hoverColor: _ToolbarTheme.hoverBlueColor, hoverColor: _ToolbarTheme.hoverBlueColor,
menuChildren: [textChat(), voiceCall()]); menuChildrenGetter: () => [textChat(), voiceCall()]);
} }
textChat() { textChat() {
@@ -1811,34 +1954,71 @@ class _VoiceCallMenu extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
menuChildrenGetter() {
final audioInput =
AudioInput(builder: (devices, currentDevice, setDevice) {
return Column(
children: devices
.map((d) => RdoMenuButton<String>(
child: Container(
child: Text(
d,
overflow: TextOverflow.ellipsis,
),
constraints: BoxConstraints(maxWidth: 250),
),
value: d,
groupValue: currentDevice,
onChanged: (v) {
if (v != null) setDevice(v);
},
ffi: ffi,
))
.toList(),
);
});
return [
audioInput,
Divider(),
MenuButton(
child: Text(translate('End call')),
onPressed: () => bind.sessionCloseVoiceCall(sessionId: ffi.sessionId),
ffi: ffi,
),
];
}
return Obx( return Obx(
() { () {
final String tooltip;
final String icon;
switch (ffi.chatModel.voiceCallStatus.value) { switch (ffi.chatModel.voiceCallStatus.value) {
case VoiceCallStatus.waitingForResponse: case VoiceCallStatus.waitingForResponse:
tooltip = "Waiting"; return buildCallWaiting(context);
icon = "assets/call_wait.svg";
break;
case VoiceCallStatus.connected: case VoiceCallStatus.connected:
tooltip = "Disconnect"; return _IconSubmenuButton(
icon = "assets/call_end.svg"; tooltip: 'Voice call',
break; svg: 'assets/voice_call.svg',
color: _ToolbarTheme.blueColor,
hoverColor: _ToolbarTheme.hoverBlueColor,
menuChildrenGetter: menuChildrenGetter,
ffi: ffi,
);
default: default:
return Offstage(); return Offstage();
} }
return _IconMenuButton(
assetName: icon,
tooltip: tooltip,
onPressed: () =>
bind.sessionCloseVoiceCall(sessionId: ffi.sessionId),
color: _ToolbarTheme.redColor,
hoverColor: _ToolbarTheme.hoverRedColor);
}, },
); );
} }
}
Widget buildCallWaiting(BuildContext context) {
return _IconMenuButton(
assetName: "assets/call_wait.svg",
tooltip: "Waiting",
onPressed: () => bind.sessionCloseVoiceCall(sessionId: ffi.sessionId),
color: _ToolbarTheme.redColor,
hoverColor: _ToolbarTheme.hoverRedColor,
);
}
}
class _RecordMenu extends StatelessWidget { class _RecordMenu extends StatelessWidget {
const _RecordMenu({Key? key}) : super(key: key); const _RecordMenu({Key? key}) : super(key: key);
@@ -1971,9 +2151,9 @@ class _IconSubmenuButton extends StatefulWidget {
final Widget? icon; final Widget? icon;
final Color color; final Color color;
final Color hoverColor; final Color hoverColor;
final List<Widget> menuChildren; final List<Widget> Function() menuChildrenGetter;
final MenuStyle? menuStyle; final MenuStyle? menuStyle;
final FFI ffi; final FFI? ffi;
final double? width; final double? width;
_IconSubmenuButton({ _IconSubmenuButton({
@@ -1983,8 +2163,8 @@ class _IconSubmenuButton extends StatefulWidget {
required this.tooltip, required this.tooltip,
required this.color, required this.color,
required this.hoverColor, required this.hoverColor,
required this.menuChildren, required this.menuChildrenGetter,
required this.ffi, this.ffi,
this.menuStyle, this.menuStyle,
this.width, this.width,
}) : super(key: key); }) : super(key: key);
@@ -2027,7 +2207,8 @@ class _IconSubmenuButtonState extends State<_IconSubmenuButton> {
color: hover ? widget.hoverColor : widget.color, color: hover ? widget.hoverColor : widget.color,
), ),
child: icon))), child: icon))),
menuChildren: widget.menuChildren menuChildren: widget
.menuChildrenGetter()
.map((e) => _buildPointerTrackWidget(e, widget.ffi)) .map((e) => _buildPointerTrackWidget(e, widget.ffi))
.toList())); .toList()));
return MenuBar(children: [ return MenuBar(children: [
@@ -2065,13 +2246,13 @@ class MenuButton extends StatelessWidget {
final VoidCallback? onPressed; final VoidCallback? onPressed;
final Widget? trailingIcon; final Widget? trailingIcon;
final Widget? child; final Widget? child;
final FFI ffi; final FFI? ffi;
MenuButton( MenuButton(
{Key? key, {Key? key,
this.onPressed, this.onPressed,
this.trailingIcon, this.trailingIcon,
required this.child, required this.child,
required this.ffi}) this.ffi})
: super(key: key); : super(key: key);
@override @override
@@ -2080,7 +2261,9 @@ class MenuButton extends StatelessWidget {
key: key, key: key,
onPressed: onPressed != null onPressed: onPressed != null
? () { ? () {
_menuDismissCallback(ffi); if (ffi != null) {
_menuDismissCallback(ffi!);
}
onPressed?.call(); onPressed?.call();
} }
: null, : null,
@@ -2093,13 +2276,13 @@ class CkbMenuButton extends StatelessWidget {
final bool? value; final bool? value;
final ValueChanged<bool?>? onChanged; final ValueChanged<bool?>? onChanged;
final Widget? child; final Widget? child;
final FFI ffi; final FFI? ffi;
const CkbMenuButton( const CkbMenuButton(
{Key? key, {Key? key,
required this.value, required this.value,
required this.onChanged, required this.onChanged,
required this.child, required this.child,
required this.ffi}) this.ffi})
: super(key: key); : super(key: key);
@override @override
@@ -2110,7 +2293,9 @@ class CkbMenuButton extends StatelessWidget {
child: child, child: child,
onChanged: onChanged != null onChanged: onChanged != null
? (bool? value) { ? (bool? value) {
_menuDismissCallback(ffi); if (ffi != null) {
_menuDismissCallback(ffi!);
}
onChanged?.call(value); onChanged?.call(value);
} }
: null, : null,
@@ -2123,13 +2308,13 @@ class RdoMenuButton<T> extends StatelessWidget {
final T? groupValue; final T? groupValue;
final ValueChanged<T?>? onChanged; final ValueChanged<T?>? onChanged;
final Widget? child; final Widget? child;
final FFI ffi; final FFI? ffi;
const RdoMenuButton({ const RdoMenuButton({
Key? key, Key? key,
required this.value, required this.value,
required this.groupValue, required this.groupValue,
required this.child, required this.child,
required this.ffi, this.ffi,
this.onChanged, this.onChanged,
}) : super(key: key); }) : super(key: key);
@@ -2141,7 +2326,9 @@ class RdoMenuButton<T> extends StatelessWidget {
child: child, child: child,
onChanged: onChanged != null onChanged: onChanged != null
? (T? value) { ? (T? value) {
_menuDismissCallback(ffi); if (ffi != null) {
_menuDismissCallback(ffi!);
}
onChanged?.call(value); onChanged?.call(value);
} }
: null, : null,
@@ -2328,10 +2515,11 @@ class InputModeMenu {
_menuDismissCallback(FFI ffi) => ffi.inputModel.refreshMousePos(); _menuDismissCallback(FFI ffi) => ffi.inputModel.refreshMousePos();
Widget _buildPointerTrackWidget(Widget child, FFI ffi) { Widget _buildPointerTrackWidget(Widget child, FFI? ffi) {
return Listener( return Listener(
onPointerHover: (PointerHoverEvent e) => onPointerHover: (PointerHoverEvent e) => {
ffi.inputModel.lastMousePos = e.position, if (ffi != null) {ffi.inputModel.lastMousePos = e.position}
},
child: MouseRegion( child: MouseRegion(
child: child, child: child,
), ),

View File

@@ -1,5 +1,4 @@
import 'dart:async'; import 'dart:async';
import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'dart:ui' as ui; import 'dart:ui' as ui;
@@ -13,11 +12,11 @@ import 'package:flutter_hbb/desktop/pages/remote_page.dart';
import 'package:flutter_hbb/main.dart'; import 'package:flutter_hbb/main.dart';
import 'package:flutter_hbb/models/platform_model.dart'; import 'package:flutter_hbb/models/platform_model.dart';
import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/models/state_model.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart'; import 'package:get/get_rx/src/rx_workers/utils/debouncer.dart';
import 'package:scroll_pos/scroll_pos.dart'; import 'package:scroll_pos/scroll_pos.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
import 'package:visibility_detector/visibility_detector.dart';
import '../../utils/multi_window_manager.dart'; import '../../utils/multi_window_manager.dart';
@@ -166,7 +165,8 @@ class DesktopTabController {
})); }));
} }
}); });
if (callOnSelected) { if ((isDesktop && (bind.isIncomingOnly() || bind.isOutgoingOnly())) ||
callOnSelected) {
if (state.value.tabs.length > index) { if (state.value.tabs.length > index) {
final key = state.value.tabs[index].key; final key = state.value.tabs[index].key;
onSelected?.call(key); onSelected?.call(key);
@@ -257,6 +257,8 @@ class DesktopTab extends StatelessWidget {
late final DesktopTabType tabType; late final DesktopTabType tabType;
late final bool isMainWindow; late final bool isMainWindow;
final RxList<String> invisibleTabKeys = RxList.empty();
DesktopTab({ DesktopTab({
Key? key, Key? key,
required this.controller, required this.controller,
@@ -375,7 +377,8 @@ class DesktopTab extends StatelessWidget {
Expanded( Expanded(
child: GestureDetector( child: GestureDetector(
// custom double tap handler // custom double tap handler
onTap: showMaximize onTap: !(bind.isIncomingOnly() && isInHomePage()) &&
showMaximize
? () { ? () {
final current = DateTime.now().millisecondsSinceEpoch; final current = DateTime.now().millisecondsSinceEpoch;
final elapsed = current - _lastClickTime; final elapsed = current - _lastClickTime;
@@ -391,20 +394,17 @@ class DesktopTab extends StatelessWidget {
child: Row( child: Row(
children: [ children: [
Offstage( Offstage(
offstage: !Platform.isMacOS, offstage: !isMacOS,
child: const SizedBox( child: const SizedBox(
width: 78, width: 78,
)), )),
Offstage( Offstage(
offstage: kUseCompatibleUiMode || Platform.isMacOS, offstage: kUseCompatibleUiMode || isMacOS,
child: Row(children: [ child: Row(children: [
Offstage( Offstage(
offstage: !showLogo, offstage: !showLogo,
child: SvgPicture.asset( child: loadIcon(16),
'assets/logo.svg', ),
width: 16,
height: 16,
)),
Offstage( Offstage(
offstage: !showTitle, offstage: !showTitle,
child: const Text( child: const Text(
@@ -433,6 +433,7 @@ class DesktopTab extends StatelessWidget {
}, },
child: _ListView( child: _ListView(
controller: controller, controller: controller,
invisibleTabKeys: invisibleTabKeys,
tabBuilder: tabBuilder, tabBuilder: tabBuilder,
tabMenuBuilder: tabMenuBuilder, tabMenuBuilder: tabMenuBuilder,
labelGetter: labelGetter, labelGetter: labelGetter,
@@ -451,12 +452,14 @@ class DesktopTab extends StatelessWidget {
tabType: tabType, tabType: tabType,
state: state, state: state,
tabController: controller, tabController: controller,
invisibleTabKeys: invisibleTabKeys,
tail: tail, tail: tail,
showMinimize: showMinimize, showMinimize: showMinimize,
showMaximize: showMaximize, showMaximize: showMaximize,
showClose: showClose, showClose: showClose,
onClose: onWindowCloseButton, onClose: onWindowCloseButton,
) labelGetter: labelGetter,
).paddingOnly(left: 10)
], ],
); );
} }
@@ -474,17 +477,22 @@ class WindowActionPanel extends StatefulWidget {
final Widget? tail; final Widget? tail;
final Future<bool> Function()? onClose; final Future<bool> Function()? onClose;
final RxList<String> invisibleTabKeys;
final LabelGetter? labelGetter;
const WindowActionPanel( const WindowActionPanel(
{Key? key, {Key? key,
required this.isMainWindow, required this.isMainWindow,
required this.tabType, required this.tabType,
required this.state, required this.state,
required this.tabController, required this.tabController,
required this.invisibleTabKeys,
this.tail, this.tail,
this.showMinimize = true, this.showMinimize = true,
this.showMaximize = true, this.showMaximize = true,
this.showClose = true, this.showClose = true,
this.onClose}) this.onClose,
this.labelGetter})
: super(key: key); : super(key: key);
@override @override
@@ -540,6 +548,16 @@ class WindowActionPanelState extends State<WindowActionPanel>
setState(() {}); setState(() {});
} }
@override
void onWindowFocus() {
stateGlobal.isFocused.value = true;
}
@override
void onWindowBlur() {
stateGlobal.isFocused.value = false;
}
@override @override
void onWindowMinimize() { void onWindowMinimize() {
stateGlobal.setMinimized(true); stateGlobal.setMinimized(true);
@@ -586,8 +604,8 @@ class WindowActionPanelState extends State<WindowActionPanel>
mainWindowClose() async => await windowManager.hide(); mainWindowClose() async => await windowManager.hide();
notMainWindowClose(WindowController controller) async { notMainWindowClose(WindowController controller) async {
if (widget.tabController.length != 0) { if (widget.tabController.length != 0) {
debugPrint("close not emtpy multiwindow from taskbar"); debugPrint("close not empty multiwindow from taskbar");
if (Platform.isWindows) { if (isWindows) {
await controller.show(); await controller.show();
await controller.focus(); await controller.focus();
final res = await widget.onClose?.call() ?? true; final res = await widget.onClose?.call() ?? true;
@@ -622,7 +640,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
await rustDeskWinManager.unregisterActiveWindow(kMainWindowId); await rustDeskWinManager.unregisterActiveWindow(kMainWindowId);
} }
// macOS specific workaround, the window is not hiding when in fullscreen. // macOS specific workaround, the window is not hiding when in fullscreen.
if (Platform.isMacOS && await windowManager.isFullScreen()) { if (isMacOS && await windowManager.isFullScreen()) {
stateGlobal.closeOnFullscreen ??= true; stateGlobal.closeOnFullscreen ??= true;
await windowManager.setFullScreen(false); await windowManager.setFullScreen(false);
await macOSWindowClose( await macOSWindowClose(
@@ -636,7 +654,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
} else { } else {
// it's safe to hide the subwindow // it's safe to hide the subwindow
final controller = WindowController.fromWindowId(kWindowId!); final controller = WindowController.fromWindowId(kWindowId!);
if (Platform.isMacOS) { if (isMacOS) {
// onWindowClose() maybe called multiple times because of loopCloseWindow() in remote_tab_page.dart. // onWindowClose() maybe called multiple times because of loopCloseWindow() in remote_tab_page.dart.
// use ??= to make sure the value is set on first call. // use ??= to make sure the value is set on first call.
@@ -661,18 +679,41 @@ class WindowActionPanelState extends State<WindowActionPanel>
super.onWindowClose(); super.onWindowClose();
} }
bool showTabDowndown() {
return widget.tabController.state.value.tabs.length > 1 &&
(widget.tabController.tabType == DesktopTabType.remoteScreen ||
widget.tabController.tabType == DesktopTabType.fileTransfer ||
widget.tabController.tabType == DesktopTabType.portForward ||
widget.tabController.tabType == DesktopTabType.cm);
}
List<String> existingInvisibleTab() {
return widget.invisibleTabKeys
.where((key) =>
widget.tabController.state.value.tabs.any((tab) => tab.key == key))
.toList();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Obx(() => Offstage(
offstage:
!(showTabDowndown() && existingInvisibleTab().isNotEmpty),
child: _TabDropDownButton(
controller: widget.tabController,
labelGetter: widget.labelGetter,
tabkeys: existingInvisibleTab()),
)),
Offstage(offstage: widget.tail == null, child: widget.tail), Offstage(offstage: widget.tail == null, child: widget.tail),
Offstage( Offstage(
offstage: kUseCompatibleUiMode, offstage: kUseCompatibleUiMode,
child: Row( child: Row(
children: [ children: [
Offstage( Offstage(
offstage: !widget.showMinimize || Platform.isMacOS, offstage: !widget.showMinimize || isMacOS,
child: ActionIcon( child: ActionIcon(
message: 'Minimize', message: 'Minimize',
icon: IconFont.min, icon: IconFont.min,
@@ -686,7 +727,7 @@ class WindowActionPanelState extends State<WindowActionPanel>
isClose: false, isClose: false,
)), )),
Offstage( Offstage(
offstage: !widget.showMaximize || Platform.isMacOS, offstage: !widget.showMaximize || isMacOS,
child: Obx(() => ActionIcon( child: Obx(() => ActionIcon(
message: stateGlobal.isMaximized.isTrue message: stateGlobal.isMaximized.isTrue
? 'Restore' ? 'Restore'
@@ -694,11 +735,13 @@ class WindowActionPanelState extends State<WindowActionPanel>
icon: stateGlobal.isMaximized.isTrue icon: stateGlobal.isMaximized.isTrue
? IconFont.restore ? IconFont.restore
: IconFont.max, : IconFont.max,
onTap: _toggleMaximize, onTap: bind.isIncomingOnly() && isInHomePage()
? null
: _toggleMaximize,
isClose: false, isClose: false,
))), ))),
Offstage( Offstage(
offstage: !widget.showClose || Platform.isMacOS, offstage: !widget.showClose || isMacOS,
child: ActionIcon( child: ActionIcon(
message: 'Close', message: 'Close',
icon: IconFont.close, icon: IconFont.close,
@@ -815,6 +858,7 @@ Future<bool> closeConfirmDialog() async {
class _ListView extends StatelessWidget { class _ListView extends StatelessWidget {
final DesktopTabController controller; final DesktopTabController controller;
final RxList<String> invisibleTabKeys;
final TabBuilder? tabBuilder; final TabBuilder? tabBuilder;
final TabMenuBuilder? tabMenuBuilder; final TabMenuBuilder? tabMenuBuilder;
@@ -826,8 +870,9 @@ class _ListView extends StatelessWidget {
Rx<DesktopTabState> get state => controller.state; Rx<DesktopTabState> get state => controller.state;
const _ListView({ _ListView({
required this.controller, required this.controller,
required this.invisibleTabKeys,
this.tabBuilder, this.tabBuilder,
this.tabMenuBuilder, this.tabMenuBuilder,
this.labelGetter, this.labelGetter,
@@ -847,6 +892,19 @@ class _ListView extends StatelessWidget {
controller.tabType == DesktopTabType.install; controller.tabType == DesktopTabType.install;
} }
onVisibilityChanged(VisibilityInfo info) {
final key = (info.key as ValueKey).value;
if (info.visibleFraction < 0.75) {
if (!invisibleTabKeys.contains(key)) {
invisibleTabKeys.add(key);
}
invisibleTabKeys.removeWhere((key) =>
controller.state.value.tabs.where((e) => e.key == key).isEmpty);
} else {
invisibleTabKeys.remove(key);
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() => ListView( return Obx(() => ListView(
@@ -859,35 +917,41 @@ class _ListView extends StatelessWidget {
: state.value.tabs.asMap().entries.map((e) { : state.value.tabs.asMap().entries.map((e) {
final index = e.key; final index = e.key;
final tab = e.value; final tab = e.value;
return _Tab( final label = labelGetter == null
? Rx<String>(tab.label)
: labelGetter!(tab.label);
return VisibilityDetector(
key: ValueKey(tab.key), key: ValueKey(tab.key),
index: index, onVisibilityChanged: onVisibilityChanged,
tabInfoKey: tab.key, child: _Tab(
label: labelGetter == null key: ValueKey(tab.key),
? Rx<String>(tab.label) index: index,
: labelGetter!(tab.label), tabInfoKey: tab.key,
selectedIcon: tab.selectedIcon, label: label,
unselectedIcon: tab.unselectedIcon, tabType: controller.tabType,
closable: tab.closable, selectedIcon: tab.selectedIcon,
selected: state.value.selected, unselectedIcon: tab.unselectedIcon,
onClose: () { closable: tab.closable,
if (tab.onTabCloseButton != null) { selected: state.value.selected,
tab.onTabCloseButton!(); onClose: () {
} else { if (tab.onTabCloseButton != null) {
controller.remove(index); tab.onTabCloseButton!();
} } else {
}, controller.remove(index);
onTap: () { }
controller.jumpTo(index); },
tab.onTap?.call(); onTap: () {
}, controller.jumpTo(index);
tabBuilder: tabBuilder, tab.onTap?.call();
tabMenuBuilder: tabMenuBuilder, },
maxLabelWidth: maxLabelWidth, tabBuilder: tabBuilder,
selectedTabBackgroundColor: selectedTabBackgroundColor ?? tabMenuBuilder: tabMenuBuilder,
MyTheme.tabbar(context).selectedTabBackgroundColor, maxLabelWidth: maxLabelWidth,
unSelectedTabBackgroundColor: unSelectedTabBackgroundColor, selectedTabBackgroundColor: selectedTabBackgroundColor ??
selectedBorderColor: selectedBorderColor, MyTheme.tabbar(context).selectedTabBackgroundColor,
unSelectedTabBackgroundColor: unSelectedTabBackgroundColor,
selectedBorderColor: selectedBorderColor,
),
); );
}).toList())); }).toList()));
} }
@@ -897,6 +961,7 @@ class _Tab extends StatefulWidget {
final int index; final int index;
final String tabInfoKey; final String tabInfoKey;
final Rx<String> label; final Rx<String> label;
final DesktopTabType tabType;
final IconData? selectedIcon; final IconData? selectedIcon;
final IconData? unselectedIcon; final IconData? unselectedIcon;
final bool closable; final bool closable;
@@ -915,6 +980,7 @@ class _Tab extends StatefulWidget {
required this.index, required this.index,
required this.tabInfoKey, required this.tabInfoKey,
required this.label, required this.label,
required this.tabType,
this.selectedIcon, this.selectedIcon,
this.unselectedIcon, this.unselectedIcon,
this.tabBuilder, this.tabBuilder,
@@ -954,7 +1020,9 @@ class _TabState extends State<_Tab> with RestorationMixin {
return ConstrainedBox( return ConstrainedBox(
constraints: BoxConstraints(maxWidth: widget.maxLabelWidth ?? 200), constraints: BoxConstraints(maxWidth: widget.maxLabelWidth ?? 200),
child: Tooltip( child: Tooltip(
message: translate(widget.label.value), message: widget.tabType == DesktopTabType.main
? ''
: translate(widget.label.value),
child: Text( child: Text(
translate(widget.label.value), translate(widget.label.value),
textAlign: TextAlign.center, textAlign: TextAlign.center,
@@ -1110,7 +1178,8 @@ class _CloseButton extends StatelessWidget {
class ActionIcon extends StatefulWidget { class ActionIcon extends StatefulWidget {
final String? message; final String? message;
final IconData icon; final IconData icon;
final Function() onTap; final GestureTapCallback? onTap;
final GestureTapDownCallback? onTapDown;
final bool isClose; final bool isClose;
final double iconSize; final double iconSize;
final double boxSize; final double boxSize;
@@ -1119,7 +1188,8 @@ class ActionIcon extends StatefulWidget {
{Key? key, {Key? key,
this.message, this.message,
required this.icon, required this.icon,
required this.onTap, this.onTap,
this.onTapDown,
this.isClose = false, this.isClose = false,
this.iconSize = _kActionIconSize, this.iconSize = _kActionIconSize,
this.boxSize = _kTabBarHeight - 1}) this.boxSize = _kTabBarHeight - 1})
@@ -1143,24 +1213,31 @@ class _ActionIconState extends State<ActionIcon> {
return Tooltip( return Tooltip(
message: widget.message != null ? translate(widget.message!) : "", message: widget.message != null ? translate(widget.message!) : "",
waitDuration: const Duration(seconds: 1), waitDuration: const Duration(seconds: 1),
child: Obx( child: InkWell(
() => InkWell( hoverColor: widget.isClose
hoverColor: widget.isClose ? const Color.fromARGB(255, 196, 43, 28)
? const Color.fromARGB(255, 196, 43, 28) : MyTheme.tabbar(context).hoverColor,
: MyTheme.tabbar(context).hoverColor, onHover: (value) => hover.value = value,
onHover: (value) => hover.value = value, onTap: widget.onTap,
onTap: widget.onTap, onTapDown: widget.onTapDown,
child: SizedBox( child: SizedBox(
height: widget.boxSize, height: widget.boxSize,
width: widget.boxSize, width: widget.boxSize,
child: Icon( child: widget.onTap == null
widget.icon, ? Icon(
color: hover.value && widget.isClose widget.icon,
? Colors.white color: Colors.grey,
: MyTheme.tabbar(context).unSelectedIconColor, size: widget.iconSize,
size: widget.iconSize, )
), : Obx(
), () => Icon(
widget.icon,
color: hover.value && widget.isClose
? Colors.white
: MyTheme.tabbar(context).unSelectedIconColor,
size: widget.iconSize,
),
),
), ),
), ),
); );
@@ -1183,6 +1260,103 @@ class AddButton extends StatelessWidget {
} }
} }
class _TabDropDownButton extends StatefulWidget {
final DesktopTabController controller;
final List<String> tabkeys;
final LabelGetter? labelGetter;
const _TabDropDownButton(
{required this.controller, required this.tabkeys, this.labelGetter});
@override
State<_TabDropDownButton> createState() => _TabDropDownButtonState();
}
class _TabDropDownButtonState extends State<_TabDropDownButton> {
var position = RelativeRect.fromLTRB(0, 0, 0, 0);
@override
Widget build(BuildContext context) {
List<String> sortedKeys = widget.controller.state.value.tabs
.where((e) => widget.tabkeys.contains(e.key))
.map((e) => e.key)
.toList();
return ActionIcon(
onTapDown: (details) {
final x = details.globalPosition.dx;
final y = details.globalPosition.dy;
position = RelativeRect.fromLTRB(x, y, x, y);
},
icon: Icons.arrow_drop_down,
onTap: () {
showMenu(
context: context,
position: position,
items: sortedKeys.map((e) {
var label = e;
final tabInfo = widget.controller.state.value.tabs
.firstWhereOrNull((element) => element.key == e);
if (tabInfo != null) {
label = tabInfo.label;
}
if (widget.labelGetter != null) {
label = widget.labelGetter!(e).value;
}
var index = widget.controller.state.value.tabs
.indexWhere((t) => t.key == e);
label = '${index + 1}. $label';
final menuHover = false.obs;
final btnHover = false.obs;
return PopupMenuItem<String>(
value: e,
height: 32,
onTap: () {
widget.controller.jumpToByKey(e);
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
}
},
child: MouseRegion(
onHover: (event) => setState(() => menuHover.value = true),
onExit: (event) => setState(() => menuHover.value = false),
child: Row(
children: [
Expanded(
child: InkWell(child: Text(label)),
),
Obx(
() => Offstage(
offstage: !(tabInfo?.onTabCloseButton != null &&
menuHover.value),
child: InkWell(
onTap: () {
tabInfo?.onTabCloseButton?.call();
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
}
},
child: MouseRegion(
cursor: SystemMouseCursors.click,
onHover: (event) =>
setState(() => btnHover.value = true),
onExit: (event) =>
setState(() => btnHover.value = false),
child: Icon(Icons.close,
color:
btnHover.value ? Colors.red : null))),
),
)
],
),
),
);
}).toList(),
);
},
);
}
}
class TabbarTheme extends ThemeExtension<TabbarTheme> { class TabbarTheme extends ThemeExtension<TabbarTheme> {
final Color? selectedTabIconColor; final Color? selectedTabIconColor;
final Color? unSelectedTabIconColor; final Color? unSelectedTabIconColor;

View File

@@ -14,21 +14,21 @@ import 'package:flutter_hbb/desktop/screen/desktop_port_forward_screen.dart';
import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart'; import 'package:flutter_hbb/desktop/screen/desktop_remote_screen.dart';
import 'package:flutter_hbb/desktop/widgets/refresh_wrapper.dart'; import 'package:flutter_hbb/desktop/widgets/refresh_wrapper.dart';
import 'package:flutter_hbb/models/state_model.dart'; import 'package:flutter_hbb/models/state_model.dart';
import 'package:flutter_hbb/plugin/handlers.dart';
import 'package:flutter_hbb/utils/multi_window_manager.dart'; import 'package:flutter_hbb/utils/multi_window_manager.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:window_manager/window_manager.dart'; import 'package:window_manager/window_manager.dart';
// import 'package:window_manager/window_manager.dart';
import 'common.dart'; import 'common.dart';
import 'consts.dart'; import 'consts.dart';
import 'mobile/pages/home_page.dart'; import 'mobile/pages/home_page.dart';
import 'mobile/pages/server_page.dart'; import 'mobile/pages/server_page.dart';
import 'models/platform_model.dart'; import 'models/platform_model.dart';
import 'package:flutter_hbb/plugin/handlers.dart'
if (dart.library.html) 'package:flutter_hbb/web/plugin/handlers.dart';
/// Basic window and launch properties. /// Basic window and launch properties.
int? kWindowId; int? kWindowId;
WindowType? kWindowType; WindowType? kWindowType;
@@ -36,6 +36,7 @@ late List<String> kBootArgs;
Future<void> main(List<String> args) async { Future<void> main(List<String> args) async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
debugPrint("launch args: $args"); debugPrint("launch args: $args");
kBootArgs = List.from(args); kBootArgs = List.from(args);
@@ -47,7 +48,7 @@ Future<void> main(List<String> args) async {
if (args.isNotEmpty && args.first == 'multi_window') { if (args.isNotEmpty && args.first == 'multi_window') {
kWindowId = int.parse(args[1]); kWindowId = int.parse(args[1]);
stateGlobal.setWindowId(kWindowId!); stateGlobal.setWindowId(kWindowId!);
if (!Platform.isMacOS) { if (!isMacOS) {
WindowController.fromWindowId(kWindowId!).showTitleBar(false); WindowController.fromWindowId(kWindowId!).showTitleBar(false);
} }
final argument = args[2].isEmpty final argument = args[2].isEmpty
@@ -58,14 +59,12 @@ Future<void> main(List<String> args) async {
// Because stateGlobal.windowId is a global value. // Because stateGlobal.windowId is a global value.
argument['windowId'] = kWindowId; argument['windowId'] = kWindowId;
kWindowType = type.windowType; kWindowType = type.windowType;
final windowName = getWindowName();
switch (kWindowType) { switch (kWindowType) {
case WindowType.RemoteDesktop: case WindowType.RemoteDesktop:
desktopType = DesktopType.remote; desktopType = DesktopType.remote;
runMultiWindow( runMultiWindow(
argument, argument,
kAppTypeDesktopRemote, kAppTypeDesktopRemote,
windowName,
); );
break; break;
case WindowType.FileTransfer: case WindowType.FileTransfer:
@@ -73,7 +72,6 @@ Future<void> main(List<String> args) async {
runMultiWindow( runMultiWindow(
argument, argument,
kAppTypeDesktopFileTransfer, kAppTypeDesktopFileTransfer,
windowName,
); );
break; break;
case WindowType.PortForward: case WindowType.PortForward:
@@ -81,7 +79,6 @@ Future<void> main(List<String> args) async {
runMultiWindow( runMultiWindow(
argument, argument,
kAppTypeDesktopPortForward, kAppTypeDesktopPortForward,
windowName,
); );
break; break;
default: default:
@@ -128,6 +125,7 @@ void runMainApp(bool startService) async {
await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]); await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]);
gFFI.userModel.refreshCurrentUser(); gFFI.userModel.refreshCurrentUser();
runApp(App()); runApp(App());
// Set window option. // Set window option.
WindowOptions windowOptions = getHiddenTitleBarWindowOptions(); WindowOptions windowOptions = getHiddenTitleBarWindowOptions();
windowManager.waitUntilReadyToShow(windowOptions, () async { windowManager.waitUntilReadyToShow(windowOptions, () async {
@@ -146,25 +144,27 @@ void runMainApp(bool startService) async {
} }
windowManager.setOpacity(1); windowManager.setOpacity(1);
windowManager.setTitle(getWindowName()); windowManager.setTitle(getWindowName());
// Do not use `windowManager.setResizable()` here.
setResizable(!bind.isIncomingOnly());
}); });
} }
void runMobileApp() async { void runMobileApp() async {
await initEnv(kAppTypeMain); await initEnv(kAppTypeMain);
if (isAndroid) androidChannelInit(); if (isAndroid) androidChannelInit();
platformFFI.syncAndroidServiceAppDirConfigPath(); if (isAndroid) platformFFI.syncAndroidServiceAppDirConfigPath();
await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]); await Future.wait([gFFI.abModel.loadCache(), gFFI.groupModel.loadCache()]);
gFFI.userModel.refreshCurrentUser(); gFFI.userModel.refreshCurrentUser();
runApp(App()); runApp(App());
await initUniLinks(); if (!isWeb) await initUniLinks();
} }
void runMultiWindow( void runMultiWindow(
Map<String, dynamic> argument, Map<String, dynamic> argument,
String appType, String appType,
String title,
) async { ) async {
await initEnv(appType); await initEnv(appType);
final title = getWindowName();
// set prevent close to true, we handle close event manually // set prevent close to true, we handle close event manually
WindowController.fromWindowId(kWindowId!).setPreventClose(true); WindowController.fromWindowId(kWindowId!).setPreventClose(true);
late Widget widget; late Widget widget;
@@ -239,7 +239,7 @@ void runConnectionManagerScreen() async {
} else { } else {
await showCmWindow(isStartup: true); await showCmWindow(isStartup: true);
} }
windowManager.setResizable(false); setResizable(false);
// Start the uni links handler and redirect links to Native, not for Flutter. // Start the uni links handler and redirect links to Native, not for Flutter.
listenUniLinks(handleByFlutter: false); listenUniLinks(handleByFlutter: false);
} }
@@ -249,7 +249,7 @@ bool _isCmReadyToShow = false;
showCmWindow({bool isStartup = false}) async { showCmWindow({bool isStartup = false}) async {
if (isStartup) { if (isStartup) {
WindowOptions windowOptions = getHiddenTitleBarWindowOptions( WindowOptions windowOptions = getHiddenTitleBarWindowOptions(
size: kConnectionManagerWindowSizeClosedChat); size: kConnectionManagerWindowSizeClosedChat, alwaysOnTop: true);
await windowManager.waitUntilReadyToShow(windowOptions, null); await windowManager.waitUntilReadyToShow(windowOptions, null);
bind.mainHideDocker(); bind.mainHideDocker();
await Future.wait([ await Future.wait([
@@ -343,7 +343,7 @@ void runInstallPage() async {
} }
WindowOptions getHiddenTitleBarWindowOptions( WindowOptions getHiddenTitleBarWindowOptions(
{Size? size, bool center = false}) { {Size? size, bool center = false, bool? alwaysOnTop}) {
var defaultTitleBarStyle = TitleBarStyle.hidden; var defaultTitleBarStyle = TitleBarStyle.hidden;
// we do not hide titlebar on win7 because of the frame overflow. // we do not hide titlebar on win7 because of the frame overflow.
if (kUseCompatibleUiMode) { if (kUseCompatibleUiMode) {
@@ -355,6 +355,7 @@ WindowOptions getHiddenTitleBarWindowOptions(
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
skipTaskbar: false, skipTaskbar: false,
titleBarStyle: defaultTitleBarStyle, titleBarStyle: defaultTitleBarStyle,
alwaysOnTop: alwaysOnTop,
); );
} }
@@ -441,6 +442,9 @@ class _AppState extends State<App> {
if (isDesktop && desktopType == DesktopType.main) { if (isDesktop && desktopType == DesktopType.main) {
child = keyListenerBuilder(context, child); child = keyListenerBuilder(context, child);
} }
if (isLinux) {
child = buildVirtualWindowFrame(context, child);
}
return child; return child;
}, },
), ),

View File

@@ -53,7 +53,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_uniLinksSubscription = listenUniLinks(); if (!isWeb) _uniLinksSubscription = listenUniLinks();
if (_idController.text.isEmpty) { if (_idController.text.isEmpty) {
() async { () async {
final lastRemoteId = await bind.mainGetLastRemoteId(); final lastRemoteId = await bind.mainGetLastRemoteId();
@@ -84,7 +84,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
slivers: [ slivers: [
SliverList( SliverList(
delegate: SliverChildListDelegate([ delegate: SliverChildListDelegate([
_buildUpdateUI(), if (!bind.isCustomClient()) _buildUpdateUI(),
_buildRemoteIDTextField(), _buildRemoteIDTextField(),
])), ])),
SliverFillRemaining( SliverFillRemaining(
@@ -166,6 +166,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
platform: '', platform: '',
tags: [], tags: [],
hash: '', hash: '',
password: '',
forceAlwaysRelay: false, forceAlwaysRelay: false,
rdpPort: '', rdpPort: '',
rdpUsername: '', rdpUsername: '',

View File

@@ -3,7 +3,6 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
import 'package:flutter_hbb/models/file_model.dart'; import 'package:flutter_hbb/models/file_model.dart';
import 'package:flutter_hbb/models/platform_model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:toggle_switch/toggle_switch.dart'; import 'package:toggle_switch/toggle_switch.dart';
import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:wakelock_plus/wakelock_plus.dart';
@@ -12,8 +11,12 @@ import '../../common.dart';
import '../../common/widgets/dialog.dart'; import '../../common/widgets/dialog.dart';
class FileManagerPage extends StatefulWidget { class FileManagerPage extends StatefulWidget {
FileManagerPage({Key? key, required this.id}) : super(key: key); FileManagerPage(
{Key? key, required this.id, this.password, this.isSharedPassword})
: super(key: key);
final String id; final String id;
final String? password;
final bool? isSharedPassword;
@override @override
State<StatefulWidget> createState() => _FileManagerPageState(); State<StatefulWidget> createState() => _FileManagerPageState();
@@ -68,7 +71,10 @@ class _FileManagerPageState extends State<FileManagerPage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
gFFI.start(widget.id, isFileTransfer: true); gFFI.start(widget.id,
isFileTransfer: true,
password: widget.password,
isSharedPassword: widget.isSharedPassword);
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
gFFI.dialogManager gFFI.dialogManager
.showLoading(translate('Connecting...'), onCancel: closeConnection); .showLoading(translate('Connecting...'), onCancel: closeConnection);

View File

@@ -4,6 +4,7 @@ import 'package:flutter_hbb/mobile/pages/settings_page.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../common.dart'; import '../../common.dart';
import '../../common/widgets/chat_page.dart'; import '../../common/widgets/chat_page.dart';
import '../../models/platform_model.dart';
import 'connection_page.dart'; import 'connection_page.dart';
abstract class PageShape extends Widget { abstract class PageShape extends Widget {
@@ -25,8 +26,9 @@ class HomePageState extends State<HomePage> {
var _selectedIndex = 0; var _selectedIndex = 0;
int get selectedIndex => _selectedIndex; int get selectedIndex => _selectedIndex;
final List<PageShape> _pages = []; final List<PageShape> _pages = [];
int _chatPageTabIndex = -1;
bool get isChatPageCurrentTab => isAndroid bool get isChatPageCurrentTab => isAndroid
? _selectedIndex == 1 ? _selectedIndex == _chatPageTabIndex
: false; // change this when ios have chat page : false; // change this when ios have chat page
void refreshPages() { void refreshPages() {
@@ -43,8 +45,9 @@ class HomePageState extends State<HomePage> {
void initPages() { void initPages() {
_pages.clear(); _pages.clear();
_pages.add(ConnectionPage()); if (!bind.isIncomingOnly()) _pages.add(ConnectionPage());
if (isAndroid) { if (isAndroid && !bind.isOutgoingOnly()) {
_chatPageTabIndex = _pages.length;
_pages.addAll([ChatPage(type: ChatPageType.mobileMain), ServerPage()]); _pages.addAll([ChatPage(type: ChatPageType.mobileMain), ServerPage()]);
} }
_pages.add(SettingsPage()); _pages.add(SettingsPage());
@@ -141,7 +144,7 @@ class HomePageState extends State<HomePage> {
], ],
); );
} }
return Text("RustDesk"); return Text(bind.mainGetAppNameSync());
} }
} }
@@ -154,7 +157,7 @@ class WebHomePage extends StatelessWidget {
// backgroundColor: MyTheme.grayBg, // backgroundColor: MyTheme.grayBg,
appBar: AppBar( appBar: AppBar(
centerTitle: true, centerTitle: true,
title: Text("RustDesk${isWeb ? " (Beta) " : ""}"), title: Text(bind.mainGetAppNameSync()),
actions: connectionPage.appBarActions, actions: connectionPage.appBarActions,
), ),
body: connectionPage, body: connectionPage,

View File

@@ -25,9 +25,12 @@ import '../widgets/dialog.dart';
final initText = '1' * 1024; final initText = '1' * 1024;
class RemotePage extends StatefulWidget { class RemotePage extends StatefulWidget {
RemotePage({Key? key, required this.id}) : super(key: key); RemotePage({Key? key, required this.id, this.password, this.isSharedPassword})
: super(key: key);
final String id; final String id;
final String? password;
final bool? isSharedPassword;
@override @override
State<RemotePage> createState() => _RemotePageState(); State<RemotePage> createState() => _RemotePageState();
@@ -54,15 +57,21 @@ class _RemotePageState extends State<RemotePage> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
gFFI.start(widget.id); gFFI.ffiModel.updateEventListener(sessionId, widget.id);
gFFI.start(
widget.id,
password: widget.password,
isSharedPassword: widget.isSharedPassword,
);
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []); SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
gFFI.dialogManager gFFI.dialogManager
.showLoading(translate('Connecting...'), onCancel: closeConnection); .showLoading(translate('Connecting...'), onCancel: closeConnection);
}); });
WakelockPlus.enable(); if (!isWeb) {
WakelockPlus.enable();
}
_physicalFocusNode.requestFocus(); _physicalFocusNode.requestFocus();
gFFI.ffiModel.updateEventListener(sessionId, widget.id);
gFFI.inputModel.listenToMouse(true); gFFI.inputModel.listenToMouse(true);
gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId); gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId);
keyboardSubscription = keyboardSubscription =
@@ -88,7 +97,9 @@ class _RemotePageState extends State<RemotePage> {
gFFI.dialogManager.dismissAll(); gFFI.dialogManager.dismissAll();
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: SystemUiOverlay.values); overlays: SystemUiOverlay.values);
await WakelockPlus.disable(); if (!isWeb) {
await WakelockPlus.disable();
}
await keyboardSubscription.cancel(); await keyboardSubscription.cancel();
removeSharedStates(widget.id); removeSharedStates(widget.id);
} }
@@ -212,7 +223,7 @@ class _RemotePageState extends State<RemotePage> {
_timer?.cancel(); _timer?.cancel();
_timer = Timer(kMobileDelaySoftKeyboard, () { _timer = Timer(kMobileDelaySoftKeyboard, () {
// show now, and sleep a while to requestFocus to // show now, and sleep a while to requestFocus to
// make sure edit ready, so that keyboard wont show/hide/show/hide happen // make sure edit ready, so that keyboard won't show/hide/show/hide happen
setState(() => _showEdit = true); setState(() => _showEdit = true);
_timer?.cancel(); _timer?.cancel();
_timer = Timer(kMobileDelaySoftKeyboardFocus, () { _timer = Timer(kMobileDelaySoftKeyboardFocus, () {
@@ -288,25 +299,26 @@ class _RemotePageState extends State<RemotePage> {
: Offstage(), : Offstage(),
], ],
)), )),
body: getRawPointerAndKeyBody(Overlay( body: Obx(
initialEntries: [ () => getRawPointerAndKeyBody(Overlay(
OverlayEntry(builder: (context) { initialEntries: [
return Container( OverlayEntry(builder: (context) {
return Container(
color: Colors.black, color: Colors.black,
child: isWebDesktop child: isWebDesktop
? getBodyForDesktopWithListener(keyboard) ? getBodyForDesktopWithListener(keyboard)
: SafeArea(child: : SafeArea(
OrientationBuilder(builder: (ctx, orientation) { child:
if (_currentOrientation != orientation) { OrientationBuilder(builder: (ctx, orientation) {
Timer(const Duration(milliseconds: 200), () { if (_currentOrientation != orientation) {
gFFI.dialogManager Timer(const Duration(milliseconds: 200), () {
.resetMobileActionsOverlay(ffi: gFFI); gFFI.dialogManager
_currentOrientation = orientation; .resetMobileActionsOverlay(ffi: gFFI);
gFFI.canvasModel.updateViewStyle(); _currentOrientation = orientation;
}); gFFI.canvasModel.updateViewStyle();
} });
return Obx( }
() => Container( return Container(
color: MyTheme.canvasColor, color: MyTheme.canvasColor,
child: inputModel.isPhysicalMouse.value child: inputModel.isPhysicalMouse.value
? getBodyForMobile() ? getBodyForMobile()
@@ -314,12 +326,14 @@ class _RemotePageState extends State<RemotePage> {
child: getBodyForMobile(), child: getBodyForMobile(),
ffi: gFFI, ffi: gFFI,
), ),
), );
); }),
}))); ),
}) );
], })
))), ],
)),
)),
); );
} }
@@ -822,6 +836,7 @@ void showOptions(
List<TRadioMenu<String>> imageQualityRadios = List<TRadioMenu<String>> imageQualityRadios =
await toolbarImageQuality(context, id, gFFI); await toolbarImageQuality(context, id, gFFI);
List<TRadioMenu<String>> codecRadios = await toolbarCodec(context, id, gFFI); List<TRadioMenu<String>> codecRadios = await toolbarCodec(context, id, gFFI);
List<TToggleMenu> cursorToggles = await toolbarCursor(context, id, gFFI);
List<TToggleMenu> displayToggles = List<TToggleMenu> displayToggles =
await toolbarDisplayToggle(context, id, gFFI); await toolbarDisplayToggle(context, id, gFFI);
@@ -862,8 +877,23 @@ void showOptions(
})), })),
if (codecRadios.isNotEmpty) const Divider(color: MyTheme.border), if (codecRadios.isNotEmpty) const Divider(color: MyTheme.border),
]; ];
final rxCursorToggleValues = cursorToggles.map((e) => e.value.obs).toList();
final cursorTogglesList = cursorToggles
.asMap()
.entries
.map((e) => Obx(() => CheckboxListTile(
contentPadding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
value: rxCursorToggleValues[e.key].value,
onChanged: (v) {
e.value.onChanged?.call(v);
if (v != null) rxCursorToggleValues[e.key].value = v;
},
title: e.value.child)))
.toList();
final rxToggleValues = displayToggles.map((e) => e.value.obs).toList(); final rxToggleValues = displayToggles.map((e) => e.value.obs).toList();
final toggles = displayToggles final displayTogglesList = displayToggles
.asMap() .asMap()
.entries .entries
.map((e) => Obx(() => CheckboxListTile( .map((e) => Obx(() => CheckboxListTile(
@@ -876,6 +906,11 @@ void showOptions(
}, },
title: e.value.child))) title: e.value.child)))
.toList(); .toList();
final toggles = [
...cursorTogglesList,
if (cursorToggles.isNotEmpty) const Divider(color: MyTheme.border),
...displayTogglesList,
];
Widget privacyModeWidget = Offstage(); Widget privacyModeWidget = Offstage();
if (privacyModeList.length > 1) { if (privacyModeList.length > 1) {

View File

@@ -8,7 +8,7 @@ import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:zxing2/qrcode.dart'; import 'package:zxing2/qrcode.dart';
import '../../common.dart'; import '../../common.dart';
import '../../consts.dart'; import '../../models/platform_model.dart';
import '../widgets/dialog.dart'; import '../widgets/dialog.dart';
class ScanPage extends StatefulWidget { class ScanPage extends StatefulWidget {
@@ -61,7 +61,7 @@ class _ScanPageState extends State<ScanPage> {
var reader = QRCodeReader(); var reader = QRCodeReader();
try { try {
var result = reader.decode(bitmap); var result = reader.decode(bitmap);
if (result.text.startsWith(kUniLinksPrefix)) { if (result.text.startsWith(bind.mainUriPrefixSync())) {
handleUriLink(uriString: result.text); handleUriLink(uriString: result.text);
} else { } else {
showServerSettingFromQr(result.text); showServerSettingFromQr(result.text);

View File

@@ -42,25 +42,21 @@ class ServerPage extends StatefulWidget implements PageShape {
return [ return [
PopupMenuItem( PopupMenuItem(
enabled: gFFI.serverModel.connectStatus > 0, enabled: gFFI.serverModel.connectStatus > 0,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
value: "changeID", value: "changeID",
child: Text(translate("Change ID")), child: Text(translate("Change ID")),
), ),
const PopupMenuDivider(), const PopupMenuDivider(),
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: 'AcceptSessionsViaPassword', value: 'AcceptSessionsViaPassword',
child: listTile( child: listTile(
'Accept sessions via password', approveMode == 'password'), 'Accept sessions via password', approveMode == 'password'),
), ),
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: 'AcceptSessionsViaClick', value: 'AcceptSessionsViaClick',
child: child:
listTile('Accept sessions via click', approveMode == 'click'), listTile('Accept sessions via click', approveMode == 'click'),
), ),
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: "AcceptSessionsViaBoth", value: "AcceptSessionsViaBoth",
child: listTile("Accept sessions via both", child: listTile("Accept sessions via both",
approveMode != 'password' && approveMode != 'click'), approveMode != 'password' && approveMode != 'click'),
@@ -69,35 +65,30 @@ class ServerPage extends StatefulWidget implements PageShape {
if (showPasswordOption && if (showPasswordOption &&
verificationMethod != kUseTemporaryPassword) verificationMethod != kUseTemporaryPassword)
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
value: "setPermanentPassword", value: "setPermanentPassword",
child: Text(translate("Set permanent password")), child: Text(translate("Set permanent password")),
), ),
if (showPasswordOption && if (showPasswordOption &&
verificationMethod != kUsePermanentPassword) verificationMethod != kUsePermanentPassword)
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
value: "setTemporaryPasswordLength", value: "setTemporaryPasswordLength",
child: Text(translate("One-time password length")), child: Text(translate("One-time password length")),
), ),
if (showPasswordOption) const PopupMenuDivider(), if (showPasswordOption) const PopupMenuDivider(),
if (showPasswordOption) if (showPasswordOption)
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: kUseTemporaryPassword, value: kUseTemporaryPassword,
child: listTile('Use one-time password', child: listTile('Use one-time password',
verificationMethod == kUseTemporaryPassword), verificationMethod == kUseTemporaryPassword),
), ),
if (showPasswordOption) if (showPasswordOption)
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: kUsePermanentPassword, value: kUsePermanentPassword,
child: listTile('Use permanent password', child: listTile('Use permanent password',
verificationMethod == kUsePermanentPassword), verificationMethod == kUsePermanentPassword),
), ),
if (showPasswordOption) if (showPasswordOption)
PopupMenuItem( PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: kUseBothPasswords, value: kUseBothPasswords,
child: listTile( child: listTile(
'Use both passwords', 'Use both passwords',
@@ -167,6 +158,7 @@ class _ServerPageState extends State<ServerPage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
buildPresetPasswordWarning(),
gFFI.serverModel.isStart gFFI.serverModel.isStart
? ServerInfo() ? ServerInfo()
: ServiceNotRunningNotification(), : ServiceNotRunningNotification(),
@@ -235,7 +227,7 @@ class ScamWarningDialog extends StatefulWidget {
} }
class ScamWarningDialogState extends State<ScamWarningDialog> { class ScamWarningDialogState extends State<ScamWarningDialog> {
int _countdown = 12; int _countdown = bind.isCustomClient() ? 0 : 12;
bool show_warning = false; bool show_warning = false;
late Timer _timer; late Timer _timer;
late ServerModel _serverModel; late ServerModel _serverModel;
@@ -392,7 +384,7 @@ class ScamWarningDialogState extends State<ScamWarningDialog> {
Navigator.of(context).pop(); Navigator.of(context).pop();
}, },
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
primary: Colors.blueAccent, backgroundColor: Colors.blueAccent,
), ),
child: Text( child: Text(
translate("Decline"), translate("Decline"),

View File

@@ -27,7 +27,7 @@ class SettingsPage extends StatefulWidget implements PageShape {
final icon = Icon(Icons.settings); final icon = Icon(Icons.settings);
@override @override
final appBarActions = [ScanButton()]; final appBarActions = bind.isDisableSettings() ? [] : [ScanButton()];
@override @override
State<SettingsPage> createState() => _SettingsState(); State<SettingsPage> createState() => _SettingsState();
@@ -218,6 +218,21 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Provider.of<FfiModel>(context); Provider.of<FfiModel>(context);
final outgoingOnly = bind.isOutgoingOnly();
final customClientSection = CustomSettingsSection(
child: Column(
children: [
if (bind.isCustomClient())
Align(
alignment: Alignment.center,
child: loadPowered(context),
),
Align(
alignment: Alignment.center,
child: loadLogo(),
)
],
));
final List<AbstractSettingsTile> enhancementsTiles = []; final List<AbstractSettingsTile> enhancementsTiles = [];
final List<AbstractSettingsTile> shareScreenTiles = [ final List<AbstractSettingsTile> shareScreenTiles = [
SettingsTile.switchTile( SettingsTile.switchTile(
@@ -448,33 +463,37 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
gFFI.invokeMethod(AndroidChannel.kSetStartOnBootOpt, toValue); gFFI.invokeMethod(AndroidChannel.kSetStartOnBootOpt, toValue);
})); }));
return SettingsList( final disabledSettings = bind.isDisableSettings();
final settings = SettingsList(
sections: [ sections: [
SettingsSection( customClientSection,
title: Text(translate('Account')), if (!bind.isDisableAccount())
tiles: [ SettingsSection(
SettingsTile( title: Text(translate('Account')),
title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty tiles: [
? translate('Login') SettingsTile(
: '${translate('Logout')} (${gFFI.userModel.userName.value})')), title: Obx(() => Text(gFFI.userModel.userName.value.isEmpty
leading: Icon(Icons.person), ? translate('Login')
onPressed: (context) { : '${translate('Logout')} (${gFFI.userModel.userName.value})')),
if (gFFI.userModel.userName.value.isEmpty) { leading: Icon(Icons.person),
loginDialog(); onPressed: (context) {
} else { if (gFFI.userModel.userName.value.isEmpty) {
logOutConfirmDialog(); loginDialog();
} } else {
}, logOutConfirmDialog();
), }
], },
), ),
],
),
SettingsSection(title: Text(translate("Settings")), tiles: [ SettingsSection(title: Text(translate("Settings")), tiles: [
SettingsTile( if (!disabledSettings)
title: Text(translate('ID/Relay Server')), SettingsTile(
leading: Icon(Icons.cloud), title: Text(translate('ID/Relay Server')),
onPressed: (context) { leading: Icon(Icons.cloud),
showServerSettings(gFFI.dialogManager); onPressed: (context) {
}), showServerSettings(gFFI.dialogManager);
}),
SettingsTile( SettingsTile(
title: Text(translate('Language')), title: Text(translate('Language')),
leading: Icon(Icons.translate), leading: Icon(Icons.translate),
@@ -494,7 +513,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
}, },
) )
]), ]),
if (isAndroid) if (isAndroid && !outgoingOnly)
SettingsSection( SettingsSection(
title: Text(translate("Recording")), title: Text(translate("Recording")),
tiles: [ tiles: [
@@ -506,7 +525,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
builder: (ctx, data) => Offstage( builder: (ctx, data) => Offstage(
offstage: !data.hasData, offstage: !data.hasData,
child: Text("${translate("Directory")}: ${data.data}")), child: Text("${translate("Directory")}: ${data.data}")),
future: bind.mainDefaultVideoSaveDirectory()), future: bind.mainVideoSaveDirectory(root: false)),
initialValue: _autoRecordIncomingSession, initialValue: _autoRecordIncomingSession,
onToggle: (v) async { onToggle: (v) async {
await bind.mainSetOption( await bind.mainSetOption(
@@ -523,13 +542,13 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
), ),
], ],
), ),
if (isAndroid) if (isAndroid && !disabledSettings && !outgoingOnly)
SettingsSection( SettingsSection(
title: Text(translate("Share Screen")), title: Text(translate("Share Screen")),
tiles: shareScreenTiles, tiles: shareScreenTiles,
), ),
defaultDisplaySection(), if (!bind.isIncomingOnly()) defaultDisplaySection(),
if (isAndroid) if (isAndroid && !disabledSettings && !outgoingOnly)
SettingsSection( SettingsSection(
title: Text(translate("Enhancements")), title: Text(translate("Enhancements")),
tiles: enhancementsTiles, tiles: enhancementsTiles,
@@ -578,6 +597,7 @@ class _SettingsState extends State<SettingsPage> with WidgetsBindingObserver {
), ),
], ],
); );
return settings;
} }
Future<bool> canStartOnBoot() async { Future<bool> canStartOnBoot() async {

View File

@@ -283,12 +283,3 @@ void setPrivacyModeDialog(
); );
}, backDismiss: true, clickMaskDismiss: true); }, backDismiss: true, clickMaskDismiss: true);
} }
Future<String?> validateAsync(String value) async {
value = value.trim();
if (value.isEmpty) {
return null;
}
final res = await bind.mainTestIfValidServer(server: value);
return res.isEmpty ? null : res;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,19 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_gpu_texture_renderer/flutter_gpu_texture_renderer.dart'; import 'package:flutter_gpu_texture_renderer/flutter_gpu_texture_renderer.dart';
import 'package:flutter_hbb/common/shared_state.dart';
import 'package:flutter_hbb/consts.dart'; import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/models/model.dart'; import 'package:flutter_hbb/models/model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:texture_rgba_renderer/texture_rgba_renderer.dart';
import '../../common.dart'; import '../../common.dart';
import './platform_model.dart'; import './platform_model.dart';
final useTextureRender = import 'package:texture_rgba_renderer/texture_rgba_renderer.dart'
bind.mainHasPixelbufferTextureRender() || bind.mainHasGpuTextureRender(); if (dart.library.html) 'package:flutter_hbb/web/texture_rgba_renderer.dart';
// Feature flutter_texture_render need to be enabled if feature vram is enabled.
final useTextureRender = !isWeb &&
(bind.mainHasPixelbufferTextureRender() || bind.mainHasGpuTextureRender());
class _PixelbufferTexture { class _PixelbufferTexture {
int _textureKey = -1; int _textureKey = -1;
@@ -36,7 +40,7 @@ class _PixelbufferTexture {
final ptr = await textureRenderer.getTexturePtr(_textureKey); final ptr = await textureRenderer.getTexturePtr(_textureKey);
platformFFI.registerPixelbufferTexture(sessionId, display, ptr); platformFFI.registerPixelbufferTexture(sessionId, display, ptr);
debugPrint( debugPrint(
"create pixelbuffer texture: peerId: ${ffi.id} display:$_display, textureId:$id"); "create pixelbuffer texture: peerId: ${ffi.id} display:$_display, textureId:$id, texturePtr:$ptr");
} }
}); });
} }
@@ -98,13 +102,15 @@ class _GpuTexture {
} }
} }
destroy(FFI ffi) async { destroy(bool unregisterTexture, FFI ffi) async {
// must stop texture render, render unregistered texture cause crash // must stop texture render, render unregistered texture cause crash
if (!_destroying && support && _sessionId != null && _textureId != -1) { if (!_destroying && support && _sessionId != null && _textureId != -1) {
_destroying = true; _destroying = true;
platformFFI.registerGpuTexture(_sessionId!, _display, 0); if (unregisterTexture) {
// sleep for a while to avoid the texture is used after it's unregistered. platformFFI.registerGpuTexture(_sessionId!, _display, 0);
await Future.delayed(Duration(milliseconds: 100)); // sleep for a while to avoid the texture is used after it's unregistered.
await Future.delayed(Duration(milliseconds: 100));
}
await gpuTextureRenderer.unregisterTexture(_textureId); await gpuTextureRenderer.unregisterTexture(_textureId);
_textureId = -1; _textureId = -1;
_destroying = false; _destroying = false;
@@ -149,40 +155,36 @@ class TextureModel {
TextureModel(this.parent); TextureModel(this.parent);
setTextureType({required int display, required bool gpuTexture}) { setTextureType({required int display, required bool gpuTexture}) {
debugPrint("setTextureType: display:$display, isGpuTexture:$gpuTexture"); debugPrint("setTextureType: display=$display, isGpuTexture=$gpuTexture");
var texture = _control[display]; ensureControl(display);
if (texture == null) { _control[display]?.setTextureType(gpuTexture: gpuTexture);
texture = _Control(); // For versions that do not support multiple displays, the display parameter is always 0, need set type of current display
_control[display] = texture; final ffi = parent.target;
if (ffi == null) return;
if (!ffi.ffiModel.pi.isSupportMultiDisplay) {
final currentDisplay = CurrentDisplayState.find(ffi.id).value;
if (currentDisplay != display) {
debugPrint(
"setTextureType: currentDisplay=$currentDisplay, isGpuTexture=$gpuTexture");
ensureControl(currentDisplay);
_control[currentDisplay]?.setTextureType(gpuTexture: gpuTexture);
}
} }
texture.setTextureType(gpuTexture: gpuTexture);
} }
setRgbaTextureId({required int display, required int id}) { setRgbaTextureId({required int display, required int id}) {
var ctl = _control[display]; ensureControl(display);
if (ctl == null) { _control[display]?.setRgbaTextureId(id);
ctl = _Control();
_control[display] = ctl;
}
ctl.setRgbaTextureId(id);
} }
setGpuTextureId({required int display, required int id}) { setGpuTextureId({required int display, required int id}) {
var ctl = _control[display]; ensureControl(display);
if (ctl == null) { _control[display]?.setGpuTextureId(id);
ctl = _Control();
_control[display] = ctl;
}
ctl.setGpuTextureId(id);
} }
RxInt getTextureId(int display) { RxInt getTextureId(int display) {
var ctl = _control[display]; ensureControl(display);
if (ctl == null) { return _control[display]!.textureID;
ctl = _Control();
_control[display] = ctl;
}
return ctl.textureID;
} }
updateCurrentDisplay(int curDisplay) { updateCurrentDisplay(int curDisplay) {
@@ -208,7 +210,7 @@ class TextureModel {
_pixelbufferRenderTextures.remove(idx); _pixelbufferRenderTextures.remove(idx);
} }
if (_gpuRenderTextures.containsKey(idx)) { if (_gpuRenderTextures.containsKey(idx)) {
_gpuRenderTextures[idx]!.destroy(ffi); _gpuRenderTextures[idx]!.destroy(true, ffi);
_gpuRenderTextures.remove(idx); _gpuRenderTextures.remove(idx);
} }
} }
@@ -235,7 +237,15 @@ class TextureModel {
await texture.destroy(closeSession, ffi); await texture.destroy(closeSession, ffi);
} }
for (final texture in _gpuRenderTextures.values) { for (final texture in _gpuRenderTextures.values) {
await texture.destroy(ffi); await texture.destroy(closeSession, ffi);
}
}
ensureControl(int display) {
var ctl = _control[display];
if (ctl == null) {
ctl = _Control();
_control[display] = ctl;
} }
} }
} }

View File

@@ -1,6 +1,5 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hbb/common.dart'; import 'package:flutter_hbb/common.dart';
@@ -292,7 +291,7 @@ class FileController {
name: isLocal ? "local_show_hidden" : "remote_show_hidden")) name: isLocal ? "local_show_hidden" : "remote_show_hidden"))
.isNotEmpty; .isNotEmpty;
options.value.isWindows = isLocal options.value.isWindows = isLocal
? Platform.isWindows ? isWindows
: rootState.target?.ffiModel.pi.platform == kPeerPlatformWindows; : rootState.target?.ffiModel.pi.platform == kPeerPlatformWindows;
await Future.delayed(Duration(milliseconds: 100)); await Future.delayed(Duration(milliseconds: 100));

View File

@@ -7,7 +7,7 @@ import 'package:flutter_hbb/models/peer_model.dart';
import 'package:flutter_hbb/models/platform_model.dart'; import 'package:flutter_hbb/models/platform_model.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart' as http; import '../utils/http_service.dart' as http;
class GroupModel { class GroupModel {
final RxBool groupLoading = false.obs; final RxBool groupLoading = false.obs;

Some files were not shown because too many files have changed in this diff Show More