Add freerdp detection

This commit is contained in:
LDprg
2023-09-10 20:07:03 +02:00
parent d8bffd817d
commit cd5c0f146c
4 changed files with 29 additions and 19 deletions

View File

@@ -7,6 +7,5 @@ edition = "2021"
[dependencies]
derive-new = "0.5.9"
home = "0.5.5"
serde = { version = "1.0.171", features = ["derive"] }
toml = "0.7.6"

View File

@@ -1,18 +1,23 @@
pub mod freerdp_back {
use crate::RemoteClient;
use std::process::{Command, Stdio};
struct Freerdp {}
use crate::{RemoteClient, Config};
pub struct Freerdp {}
impl RemoteClient for Freerdp {
fn check_depends(&self) {
todo!()
fn check_depends(&self, _config: Config) {
let mut xfreerdp = Command::new("xfreerdp");
xfreerdp.stdout(Stdio::null());
xfreerdp.args(["-h"]);
xfreerdp.spawn().expect("Freerdp execution failed! It needs to be installed!");
println!("Freerdp found!");
println!("Checks success!");
}
fn load_config(&self, _path: &str) {
todo!()
}
fn run_app(&self, _app: &str) {
fn run_app(&self, config: Config, _app: &str) {
todo!()
}
}

View File

@@ -1,20 +1,18 @@
use derive_new::new;
use home::home_dir;
use serde::{Deserialize, Serialize};
use std::io::Write;
use std::{
env,
fs::{self, File},
path::Path,
};
mod freerdp;
pub mod freerdp;
pub trait RemoteClient {
fn check_depends(&self);
fn check_depends(&self, config: Config);
fn load_config(&self, path: &str);
fn run_app(&self, app: &str);
fn run_app(&self, config: Config, app: &str);
}
#[derive(new, Debug, Deserialize, Serialize)]
@@ -44,8 +42,8 @@ pub struct RemoteConfig {
}
pub fn load_config(path: Option<&str>) -> Config {
let home = home_dir().expect("Could not find the home path!");
let default = &format!("{}{}", home.to_str().unwrap(), "/.config/winapps/");
let config = env::var("XDG_CONFIG_HOME").expect("Could not find the home path!");
let default = &format!("{}{}", config, "/winapps/");
let path = Path::new(path.unwrap_or(default));
let config = Config::new();