Merge pull request #2225 from 21pages/portable-service

portable-service: enable quick support by rename as xxxqs.exe
This commit is contained in:
RustDesk 2022-11-19 13:53:21 +08:00 committed by GitHub
commit ac07db76cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 49 additions and 46 deletions

View File

@ -15,7 +15,7 @@ env:
jobs: jobs:
build-for-windows: build-for-windows:
name: ${{ matrix.job.target }} (${{ matrix.job.os }}) ${{ matrix.job.suffix }} name: ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }} runs-on: ${{ matrix.job.os }}
strategy: strategy:
fail-fast: false fail-fast: false
@ -23,8 +23,7 @@ jobs:
job: job:
# - { target: i686-pc-windows-msvc , os: windows-2019 } # - { target: i686-pc-windows-msvc , os: windows-2019 }
# - { target: x86_64-pc-windows-gnu , os: windows-2019 } # - { target: x86_64-pc-windows-gnu , os: windows-2019 }
- { target: x86_64-pc-windows-msvc , os: windows-2019, suffix: "" , extra-build-args: "" } - { target: x86_64-pc-windows-msvc , os: windows-2019 }
- { target: x86_64-pc-windows-msvc , os: windows-2019, suffix: "-qs", extra-build-args: "--quick_start" }
steps: steps:
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -84,13 +83,13 @@ jobs:
shell: bash shell: bash
- name: Build rustdesk - name: Build rustdesk
run: python3 .\build.py --portable --hwcodec --flutter ${{ matrix.job.extra-build-args }} run: python3 .\build.py --portable --hwcodec --flutter
- name: Rename rustdesk - name: Rename rustdesk
shell: bash shell: bash
run: | run: |
for name in rustdesk*??-install.exe; do for name in rustdesk*??-install.exe; do
mv "$name" "${name%%-install.exe}-${{ matrix.job.target }}${{ matrix.job.suffix }}.exe" mv "$name" "${name%%-install.exe}-${{ matrix.job.target }}.exe"
done done
- name: Publish Release - name: Publish Release

View File

@ -29,7 +29,6 @@ flutter = ["flutter_rust_bridge"]
default = ["use_dasp"] default = ["use_dasp"]
hwcodec = ["scrap/hwcodec"] hwcodec = ["scrap/hwcodec"]
mediacodec = ["scrap/mediacodec"] mediacodec = ["scrap/mediacodec"]
quick_start = []
# 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

View File

@ -81,11 +81,6 @@ def make_parser():
action='store_true', action='store_true',
help='Build windows portable' help='Build windows portable'
) )
parser.add_argument(
'--quick_start',
action='store_true',
help='Windows quick start portable'
)
parser.add_argument( parser.add_argument(
'--flatpak', '--flatpak',
action='store_true', action='store_true',
@ -194,8 +189,6 @@ def get_features(args):
features = ['inline'] features = ['inline']
if windows: if windows:
features.extend(get_rc_features(args)) features.extend(get_rc_features(args))
if args.quick_start:
features.append('quick_start')
if args.hwcodec: if args.hwcodec:
features.append('hwcodec') features.append('hwcodec')
if args.flutter: if args.flutter:

View File

@ -90,12 +90,15 @@ class _ConnectionPageState extends State<ConnectionPage>
Get.forceAppUpdate(); Get.forceAppUpdate();
} }
isWindowMinisized = false; isWindowMinisized = false;
} else if (eventName == 'close') {
// called more then one time
bind.mainOnMainWindowClose();
} }
} }
@override
void onWindowClose() {
super.onWindowClose();
bind.mainOnMainWindowClose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(

View File

@ -64,6 +64,7 @@ fn main() {
i += 1; i += 1;
} }
let click_setup = args.is_empty() && arg_exe.to_lowercase().ends_with("install.exe"); let click_setup = args.is_empty() && arg_exe.to_lowercase().ends_with("install.exe");
let quick_support = args.is_empty() && arg_exe.to_lowercase().ends_with("qs.exe");
let reader = BinaryReader::default(); let reader = BinaryReader::default();
if let Some(exe) = setup( if let Some(exe) = setup(
@ -72,7 +73,9 @@ fn main() {
click_setup || args.contains(&"--silent-install".to_owned()), click_setup || args.contains(&"--silent-install".to_owned()),
) { ) {
if click_setup { if click_setup {
args = vec!["--install".to_owned()] args = vec!["--install".to_owned()];
} else if quick_support {
args = vec!["--quick_support".to_owned()];
} }
execute(exe, args); execute(exe, args);
} }

View File

@ -14,6 +14,7 @@ pub fn core_main() -> Option<Vec<String>> {
let mut i = 0; let mut i = 0;
let mut _is_elevate = false; let mut _is_elevate = false;
let mut _is_run_as_system = false; let mut _is_run_as_system = false;
let mut _is_quick_support = false;
let mut _is_flutter_connect = false; let mut _is_flutter_connect = false;
let mut arg_exe = Default::default(); let mut arg_exe = Default::default();
for arg in std::env::args() { for arg in std::env::args() {
@ -29,6 +30,8 @@ pub fn core_main() -> Option<Vec<String>> {
_is_elevate = true; _is_elevate = true;
} else if arg == "--run-as-system" { } else if arg == "--run-as-system" {
_is_run_as_system = true; _is_run_as_system = true;
} else if arg == "--quick_support" {
_is_quick_support = true;
} else { } else {
args.push(arg); args.push(arg);
} }
@ -40,6 +43,11 @@ pub fn core_main() -> Option<Vec<String>> {
return core_main_invoke_new_connection(std::env::args()); return core_main_invoke_new_connection(std::env::args());
} }
let click_setup = cfg!(windows) && args.is_empty() && crate::common::is_setup(&arg_exe); let click_setup = cfg!(windows) && args.is_empty() && crate::common::is_setup(&arg_exe);
#[cfg(not(feature = "flutter"))]
{
_is_quick_support =
cfg!(windows) && args.is_empty() && arg_exe.to_lowercase().ends_with("qs.exe");
}
if click_setup { if click_setup {
args.push("--install".to_owned()); args.push("--install".to_owned());
flutter_args.push("--install".to_string()); flutter_args.push("--install".to_string());
@ -81,8 +89,12 @@ pub fn core_main() -> Option<Vec<String>> {
} }
} }
#[cfg(windows)] #[cfg(windows)]
#[cfg(feature = "quick_start")] if !crate::platform::is_installed()
if !crate::platform::is_installed() && args.is_empty() && !_is_elevate && !_is_run_as_system { && args.is_empty()
&& _is_quick_support
&& !_is_elevate
&& !_is_run_as_system
{
if let Err(e) = crate::portable_service::client::start_portable_service() { if let Err(e) = crate::portable_service::client::start_portable_service() {
log::error!("Failed to start portable service:{:?}", e); log::error!("Failed to start portable service:{:?}", e);
} }

View File

@ -1178,6 +1178,7 @@ pub fn main_account_auth_result() -> String {
} }
pub fn main_on_main_window_close() { pub fn main_on_main_window_close() {
// may called more than one times
#[cfg(windows)] #[cfg(windows)]
crate::portable_service::client::drop_portable_service_shared_memory(); crate::portable_service::client::drop_portable_service_shared_memory();
} }

View File

@ -237,11 +237,10 @@ pub mod server {
fn run_exit_check() { fn run_exit_check() {
loop { loop {
if EXIT.lock().unwrap().clone() { if EXIT.lock().unwrap().clone() {
std::thread::sleep(Duration::from_secs(1)); std::thread::sleep(Duration::from_millis(50));
log::info!("exit from seperate check thread");
std::process::exit(0); std::process::exit(0);
} }
std::thread::sleep(Duration::from_secs(1)); std::thread::sleep(Duration::from_millis(50));
} }
} }
@ -406,9 +405,8 @@ pub mod server {
Pong => { Pong => {
nack = 0; nack = 0;
} }
ConnCount(Some(_n)) => { ConnCount(Some(n)) => {
#[cfg(not(feature = "quick_start"))] if n == 0 {
if _n == 0 {
log::info!("Connnection count equals 0, exit"); log::info!("Connnection count equals 0, exit");
stream.send(&Data::DataPortableService(WillClose)).await.ok(); stream.send(&Data::DataPortableService(WillClose)).await.ok();
break; break;
@ -436,7 +434,6 @@ pub mod server {
break; break;
} }
stream.send(&Data::DataPortableService(Ping)).await.ok(); stream.send(&Data::DataPortableService(Ping)).await.ok();
#[cfg(not(feature = "quick_start"))]
stream.send(&Data::DataPortableService(ConnCount(None))).await.ok(); stream.send(&Data::DataPortableService(ConnCount(None))).await.ok();
} }
} }
@ -626,6 +623,17 @@ pub mod client {
use DataPortableService::*; use DataPortableService::*;
let rx = Arc::new(tokio::sync::Mutex::new(rx)); let rx = Arc::new(tokio::sync::Mutex::new(rx));
let postfix = IPC_PROFIX; let postfix = IPC_PROFIX;
#[cfg(feature = "flutter")]
let quick_support = {
let args: Vec<_> = std::env::args().collect();
args.contains(&"--quick_support".to_string())
};
#[cfg(not(feature = "flutter"))]
let quick_support = std::env::current_exe()
.unwrap_or("".into())
.to_string_lossy()
.to_lowercase()
.ends_with("qs.exe");
match new_listener(postfix).await { match new_listener(postfix).await {
Ok(mut incoming) => loop { Ok(mut incoming) => loop {
@ -663,8 +671,10 @@ pub mod client {
*PORTABLE_SERVICE_RUNNING.lock().unwrap() = true; *PORTABLE_SERVICE_RUNNING.lock().unwrap() = true;
}, },
ConnCount(None) => { ConnCount(None) => {
let cnt = crate::server::CONN_COUNT.lock().unwrap().clone(); if !quick_support {
stream.send(&Data::DataPortableService(ConnCount(Some(cnt)))).await.ok(); let cnt = crate::server::CONN_COUNT.lock().unwrap().clone();
stream.send(&Data::DataPortableService(ConnCount(Some(cnt)))).await.ok();
}
}, },
WillClose => { WillClose => {
log::info!("portable service will close"); log::info!("portable service will close");

View File

@ -15,7 +15,7 @@ use hbb_common::{
protobuf::Message as _, protobuf::Message as _,
rendezvous_proto::*, rendezvous_proto::*,
tcp::FramedStream, tcp::FramedStream,
tokio::{self, sync::mpsc}, tokio,
}; };
use crate::common::get_app_name; use crate::common::get_app_name;
@ -44,23 +44,6 @@ lazy_static::lazy_static! {
struct UIHostHandler; struct UIHostHandler;
// to-do: dead code?
fn check_connect_status(
reconnect: bool,
) -> (
Arc<Mutex<Status>>,
Arc<Mutex<HashMap<String, String>>>,
mpsc::UnboundedSender<ipc::Data>,
Arc<Mutex<String>>,
) {
let status = Arc::new(Mutex::new((0, false, 0, "".to_owned())));
let options = Arc::new(Mutex::new(Config::get_options()));
let (tx, rx) = mpsc::unbounded_channel::<ipc::Data>();
let password = Arc::new(Mutex::new(String::default()));
std::thread::spawn(move || crate::ui_interface::check_connect_status_(reconnect, rx));
(status, options, tx, password)
}
pub fn start(args: &mut [String]) { pub fn start(args: &mut [String]) {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
macos::show_dock(); macos::show_dock();