mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix default video save directory
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -860,10 +860,11 @@ impl VideoHandler {
|
||||
if start {
|
||||
self.recorder = Recorder::new(RecorderContext {
|
||||
id,
|
||||
default_dir: crate::ui_interface::default_video_save_directory(),
|
||||
filename: "".to_owned(),
|
||||
width: w as _,
|
||||
height: h as _,
|
||||
codec_id: scrap::record::RecodeCodecID::VP9,
|
||||
codec_id: scrap::record::RecordCodecID::VP9,
|
||||
})
|
||||
.map_or(Default::default(), |r| Arc::new(Mutex::new(Some(r))));
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,9 @@ pub fn core_main() -> Option<Vec<String>> {
|
||||
}
|
||||
if _is_connect {
|
||||
return core_main_invoke_new_connection(std::env::args());
|
||||
}
|
||||
if args.contains(&"--install".to_string()) {
|
||||
is_setup = true;
|
||||
}
|
||||
if is_setup {
|
||||
if args.is_empty() {
|
||||
|
||||
@@ -4,6 +4,7 @@ use hbb_common::{allow_err, bail, log};
|
||||
use libc::{c_char, c_int, c_void};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
path::PathBuf,
|
||||
sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
@@ -516,6 +517,17 @@ pub fn get_active_username() -> String {
|
||||
get_value_of_seat0(2)
|
||||
}
|
||||
|
||||
pub fn get_active_user_home() -> Option<PathBuf> {
|
||||
let username = get_active_username();
|
||||
if !username.is_empty() {
|
||||
let home = PathBuf::from(format!("/home/{}", username));
|
||||
if home.exists() {
|
||||
return Some(home);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_prelogin() -> bool {
|
||||
let n = get_active_userid().len();
|
||||
n < 4 && n > 1
|
||||
|
||||
@@ -20,6 +20,7 @@ use hbb_common::{bail, log};
|
||||
use include_dir::{include_dir, Dir};
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
use scrap::{libc::c_void, quartz::ffi::*};
|
||||
use std::path::PathBuf;
|
||||
|
||||
static PRIVILEGES_SCRIPTS_DIR: Dir =
|
||||
include_dir!("$CARGO_MANIFEST_DIR/src/platform/privileges_scripts");
|
||||
@@ -374,6 +375,17 @@ pub fn get_active_userid() -> String {
|
||||
get_active_user("-n")
|
||||
}
|
||||
|
||||
pub fn get_active_user_home() -> Option<PathBuf> {
|
||||
let username = get_active_username();
|
||||
if !username.is_empty() {
|
||||
let home = PathBuf::from(format!("/Users/{}", username));
|
||||
if home.exists() {
|
||||
return Some(home);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_prelogin() -> bool {
|
||||
get_active_userid() == "0"
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ use std::io::prelude::*;
|
||||
use std::{
|
||||
ffi::{CString, OsString},
|
||||
fs, io, mem,
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
@@ -734,6 +735,18 @@ pub fn get_active_username() -> String {
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
pub fn get_active_user_home() -> Option<PathBuf> {
|
||||
let username = get_active_username();
|
||||
if !username.is_empty() {
|
||||
let drive = std::env::var("SystemDrive").unwrap_or("C:".to_owned());
|
||||
let home = PathBuf::from(format!("{}\\Users\\{}", drive, username));
|
||||
if home.exists() {
|
||||
return Some(home);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_prelogin() -> bool {
|
||||
let username = get_active_username();
|
||||
username.is_empty() || username == "SYSTEM"
|
||||
|
||||
@@ -443,10 +443,11 @@ fn run(sp: GenericService) -> ResultType<()> {
|
||||
let recorder = if !Config::get_option("allow-auto-record-incoming").is_empty() {
|
||||
Recorder::new(RecorderContext {
|
||||
id: "local".to_owned(),
|
||||
default_dir: crate::ui_interface::default_video_save_directory(),
|
||||
filename: "".to_owned(),
|
||||
width: c.width,
|
||||
height: c.height,
|
||||
codec_id: scrap::record::RecodeCodecID::VP9,
|
||||
codec_id: scrap::record::RecordCodecID::VP9,
|
||||
})
|
||||
.map_or(Default::default(), |r| Arc::new(Mutex::new(Some(r))))
|
||||
} else {
|
||||
|
||||
@@ -10,6 +10,7 @@ use hbb_common::password_security;
|
||||
use hbb_common::{
|
||||
allow_err,
|
||||
config::{self, Config, LocalConfig, PeerConfig, RENDEZVOUS_PORT, RENDEZVOUS_TIMEOUT},
|
||||
directories_next,
|
||||
futures::future::join_all,
|
||||
log,
|
||||
protobuf::Message as _,
|
||||
@@ -19,8 +20,8 @@ use hbb_common::{
|
||||
tokio::{self, sync::mpsc, time},
|
||||
};
|
||||
|
||||
use crate::common::SOFTWARE_UPDATE_URL;
|
||||
use crate::ipc;
|
||||
use crate::{common::SOFTWARE_UPDATE_URL, platform};
|
||||
|
||||
type Message = RendezvousMessage;
|
||||
|
||||
@@ -731,7 +732,26 @@ pub fn get_langs() -> String {
|
||||
|
||||
#[inline]
|
||||
pub fn default_video_save_directory() -> String {
|
||||
scrap::record::RecorderContext::default_save_directory()
|
||||
let appname = crate::get_app_name();
|
||||
if let Some(user) = directories_next::UserDirs::new() {
|
||||
if let Some(video_dir) = user.video_dir() {
|
||||
return video_dir.join(appname).to_string_lossy().to_string();
|
||||
}
|
||||
}
|
||||
if let Some(home) = platform::get_active_user_home() {
|
||||
let name = if cfg!(target_os = "macos") {
|
||||
"Movies"
|
||||
} else {
|
||||
"Videos"
|
||||
};
|
||||
return home.join(name).join(appname).to_string_lossy().to_string();
|
||||
}
|
||||
if let Ok(exe) = std::env::current_exe() {
|
||||
if let Some(dir) = exe.parent() {
|
||||
return dir.join("videos").to_string_lossy().to_string();
|
||||
}
|
||||
}
|
||||
"".to_owned()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
||||
Reference in New Issue
Block a user