From 2fe695f642a25914c2ce5fc393179aa100ea8966 Mon Sep 17 00:00:00 2001 From: Ishan Kumar Date: Mon, 11 Aug 2025 12:25:47 +0530 Subject: [PATCH] chore: adding windows support scaffold --- src/bluetooth/discovery.rs | 3 +++ src/fsm/sender_fsm.rs | 3 ++- src/main.rs | 1 + src/tunnel/connection.rs | 3 +++ src/tunnel/transfer.rs | 4 ++++ src/windows/bluetooth.rs | 28 ++++++++++++++++++++++++++++ src/windows/connection.rs | 15 +++++++++++++++ src/windows/mod.rs | 4 ++++ src/windows/transfer.rs | 18 ++++++++++++++++++ 9 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/windows/bluetooth.rs create mode 100644 src/windows/connection.rs create mode 100644 src/windows/mod.rs create mode 100644 src/windows/transfer.rs diff --git a/src/bluetooth/discovery.rs b/src/bluetooth/discovery.rs index 55c286a..2dbd486 100644 --- a/src/bluetooth/discovery.rs +++ b/src/bluetooth/discovery.rs @@ -4,4 +4,7 @@ use crate::linux::bluetooth; #[cfg(target_os="macos")] use crate::macos::bluetooth; +#[cfg(target_os="windows")] +use crate::windows::bluetooth; + pub use bluetooth::*; \ No newline at end of file diff --git a/src/fsm/sender_fsm.rs b/src/fsm/sender_fsm.rs index dccbb7d..d5807ff 100644 --- a/src/fsm/sender_fsm.rs +++ b/src/fsm/sender_fsm.rs @@ -1,4 +1,5 @@ -#![cfg(target_os="linux")] +#![cfg(any(target_os = "linux", target_os = "windows"))] + use dialoguer::{Select, theme::ColorfulTheme}; use std::time::Duration; diff --git a/src/main.rs b/src/main.rs index 6f0920c..ace41ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use utils::cli::{Cli, Commands}; mod tunnel; mod linux; mod macos; +mod windows; mod crypto; use tokio::signal; diff --git a/src/tunnel/connection.rs b/src/tunnel/connection.rs index 7087040..629f4a3 100644 --- a/src/tunnel/connection.rs +++ b/src/tunnel/connection.rs @@ -4,4 +4,7 @@ use crate::linux::connection; #[cfg(target_os = "macos")] use crate::macos::connection; +#[cfg(target_os = "windows")] +use crate::windows::connection; + pub use connection::*; \ No newline at end of file diff --git a/src/tunnel/transfer.rs b/src/tunnel/transfer.rs index e90e6bb..8feffc9 100644 --- a/src/tunnel/transfer.rs +++ b/src/tunnel/transfer.rs @@ -4,4 +4,8 @@ use crate::linux::transfer; #[cfg(target_os = "macos")] use crate::macos::transfer; +#[cfg(target_os="windows")] +use crate::windows::transfer; + + pub use transfer::*; \ No newline at end of file diff --git a/src/windows/bluetooth.rs b/src/windows/bluetooth.rs new file mode 100644 index 0000000..63652a1 --- /dev/null +++ b/src/windows/bluetooth.rs @@ -0,0 +1,28 @@ +use std::error::Error; +use std::time::{Duration, Instant}; +use tokio::time::sleep; + +#[derive(Clone, Debug)] + + +impl AdapterController { + pub async fn initialize() -> Result {} + + pub async fn scan_devices( + &self, + timeout_secs: Duration, + ) -> Result, Box> {} + + pub async fn serve_gatt( + &self, + key_data: Vec, + expected_mac: String, + ) -> Result<(), Box> {} +} + +pub async fn receive_fling_key() -> Result, Box> { +} + +pub fn get_bluetooth_mac() -> Option { + +} \ No newline at end of file diff --git a/src/windows/connection.rs b/src/windows/connection.rs new file mode 100644 index 0000000..e2176a8 --- /dev/null +++ b/src/windows/connection.rs @@ -0,0 +1,15 @@ +use std::{process::Command, time::Duration}; +use tokio::time::sleep; + +/// Launches a Wi-Fi Direct access point using hostapd and sets up DHCP +pub async fn create_wifi_direct_network(ssid: &str, password: &str) -> Result {} + +/// Waits up to 30 seconds for a client to join the AP +pub async fn wait_for_receiver() -> Result {} + +pub async fn cleanup_wifi() {} + +///Joins a Full AP network controlled by sender +pub fn join_wifi_direct_network(ssid: &str, password: &str) -> bool {} + + diff --git a/src/windows/mod.rs b/src/windows/mod.rs new file mode 100644 index 0000000..e17dea6 --- /dev/null +++ b/src/windows/mod.rs @@ -0,0 +1,4 @@ +#![cfg(target_os="windows")] +pub mod transfer; +pub mod connection; +pub mod bluetooth; \ No newline at end of file diff --git a/src/windows/transfer.rs b/src/windows/transfer.rs new file mode 100644 index 0000000..6de52c5 --- /dev/null +++ b/src/windows/transfer.rs @@ -0,0 +1,18 @@ +use indicatif::{ProgressBar, ProgressStyle}; +use std::path::Path; +use std::process::Stdio; +use std::time::Instant; +use tokio::{ + fs::File, + io::{AsyncReadExt, AsyncWriteExt, BufReader}, + net::TcpListener, + process::Command, + time::{Duration}, +}; + +const PORT: u16 = 8080; +const BUF_SIZE: usize = 1024 * 1024; + +pub async fn send_file(filepath: &str) -> Result<(), String> {} + +pub async fn receive_file(output_dir: &str) -> Result<(), String> {} \ No newline at end of file