mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-06 15:17:19 +02:00
Add freerdp detection
This commit is contained in:
parent
d8bffd817d
commit
cd5c0f146c
@ -1,4 +1,6 @@
|
|||||||
use clap::Command;
|
use clap::Command;
|
||||||
|
use winapps::RemoteClient;
|
||||||
|
use winapps::freerdp::freerdp_back::Freerdp;
|
||||||
|
|
||||||
fn cli() -> Command {
|
fn cli() -> Command {
|
||||||
Command::new("winapps-cli")
|
Command::new("winapps-cli")
|
||||||
@ -14,14 +16,20 @@ fn main() {
|
|||||||
let cli = cli();
|
let cli = cli();
|
||||||
let matches = cli.clone().get_matches();
|
let matches = cli.clone().get_matches();
|
||||||
|
|
||||||
|
let client: &dyn RemoteClient = &Freerdp{};
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
Some(("check", _)) => {
|
Some(("check", _)) => {
|
||||||
println!("Checking remote connection");
|
println!("Checking remote connection");
|
||||||
|
|
||||||
let _config = winapps::load_config(None);
|
let config = winapps::load_config(None);
|
||||||
|
client.check_depends(config);
|
||||||
}
|
}
|
||||||
Some(("connect", _)) => {
|
Some(("connect", _)) => {
|
||||||
println!("Connecting to remote");
|
println!("Connecting to remote");
|
||||||
|
|
||||||
|
let config = winapps::load_config(None);
|
||||||
|
client.run_app(config, "explorer");
|
||||||
}
|
}
|
||||||
Some((_, _)) => {
|
Some((_, _)) => {
|
||||||
cli.about("Command not found, try existing ones!")
|
cli.about("Command not found, try existing ones!")
|
||||||
|
@ -7,6 +7,5 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
derive-new = "0.5.9"
|
derive-new = "0.5.9"
|
||||||
home = "0.5.5"
|
|
||||||
serde = { version = "1.0.171", features = ["derive"] }
|
serde = { version = "1.0.171", features = ["derive"] }
|
||||||
toml = "0.7.6"
|
toml = "0.7.6"
|
||||||
|
@ -1,18 +1,23 @@
|
|||||||
pub mod freerdp_back {
|
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 {
|
impl RemoteClient for Freerdp {
|
||||||
fn check_depends(&self) {
|
fn check_depends(&self, _config: Config) {
|
||||||
todo!()
|
|
||||||
|
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) {
|
fn run_app(&self, config: Config, _app: &str) {
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_app(&self, _app: &str) {
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use home::home_dir;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::{
|
use std::{
|
||||||
|
env,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
path::Path,
|
path::Path,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod freerdp;
|
pub mod freerdp;
|
||||||
|
|
||||||
pub trait RemoteClient {
|
pub trait RemoteClient {
|
||||||
fn check_depends(&self);
|
fn check_depends(&self, config: Config);
|
||||||
|
|
||||||
fn load_config(&self, path: &str);
|
fn run_app(&self, config: Config, app: &str);
|
||||||
|
|
||||||
fn run_app(&self, app: &str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(new, Debug, Deserialize, Serialize)]
|
#[derive(new, Debug, Deserialize, Serialize)]
|
||||||
@ -44,8 +42,8 @@ pub struct RemoteConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_config(path: Option<&str>) -> Config {
|
pub fn load_config(path: Option<&str>) -> Config {
|
||||||
let home = home_dir().expect("Could not find the home path!");
|
let config = env::var("XDG_CONFIG_HOME").expect("Could not find the home path!");
|
||||||
let default = &format!("{}{}", home.to_str().unwrap(), "/.config/winapps/");
|
let default = &format!("{}{}", config, "/winapps/");
|
||||||
let path = Path::new(path.unwrap_or(default));
|
let path = Path::new(path.unwrap_or(default));
|
||||||
let config = Config::new();
|
let config = Config::new();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user