Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,058 changes: 222 additions & 836 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ tokio = { version = "1", features = ["full"] }
tracing = "0.1"
tracing-subscriber = "0.3"

tray-icon = "0.14"
gtk = "0.18"
ksni = "0.3"
gio = "0.20"

zbus = "4"
uuid = { version = "1", features = ["v4"] }
Expand Down
4 changes: 2 additions & 2 deletions data/io.github.AghastyGD.Wiretray.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<summary>Hotspot SSID</summary>
</key>

<key name="password" type="s">
<key name="passphrase" type="s">
<default>''</default>
<summary>Hotspot password</summary>
<summary>Hotspot passphrase</summary>
</key>
</schema>
</schemalist>
15 changes: 4 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@ use anyhow::Result;

use wiretray::tray;

fn main() -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
setup_logging();

tracing::info!("Starting wiretray...");
tracing::info!("Starting Wiretray...");

gtk::init()?;

let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()?;

tray::run(rt.handle().clone())?;

Ok(())
tray::run().await
}

fn setup_logging() {
Expand Down
2 changes: 1 addition & 1 deletion src/models/hotspot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub enum HotspotBackend {
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HotspotStartRequest {
pub struct HotspotConfig {
pub interface: String,
pub ssid: String,
pub passphrase: Option<String>,
Expand Down
10 changes: 5 additions & 5 deletions src/services/hotspot_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use zbus::zvariant::Value;
use crate::models::{
device::Device,
hotspot::{
ActiveHotspot, HotspotBackend, HotspotCapability, HotspotConnectionState,
HotspotRadioState, HotspotStartRequest,
ActiveHotspot, HotspotBackend, HotspotCapability, HotspotConfig, HotspotConnectionState,
HotspotRadioState,
},
};

Expand Down Expand Up @@ -75,7 +75,7 @@ impl HotspotService {
}
}

pub async fn start(&self, request: HotspotStartRequest) -> Result<ActiveHotspot> {
pub async fn start(&self, request: HotspotConfig) -> Result<ActiveHotspot> {
validate_start_request(&request)?;

match &self.backend {
Expand Down Expand Up @@ -227,7 +227,7 @@ async fn find_active_hotspot(
Ok(None)
}

fn validate_start_request(request: &HotspotStartRequest) -> Result<()> {
fn validate_start_request(request: &HotspotConfig) -> Result<()> {
if request.interface.trim().is_empty() {
bail!("Hotspot interface is required");
}
Expand Down Expand Up @@ -257,7 +257,7 @@ fn hotspot_connection_id(interface: &str) -> String {
}

fn build_hotspot_settings(
request: &HotspotStartRequest,
request: &HotspotConfig,
connection_id: &str,
connection_uuid: &str,
) -> crate::dbus::network_manager::ConnectionSettings {
Expand Down
2 changes: 1 addition & 1 deletion src/settings/hotspot_settings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HotspotSettings {
pub ssid: String,
pub password: String,
pub passphrase: String,
}
11 changes: 6 additions & 5 deletions src/settings/service.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use anyhow::Result;
use gtk::gio::Settings;
use gtk::prelude::SettingsExt;
use gio::Settings;
use gio::prelude::SettingsExt;

use super::hotspot_settings::HotspotSettings;

const SCHEMA_ID: &str = "io.github.AghastyGD.Wiretray";

const KEY_SSID: &str = "ssid";
const KEY_PASSWORD: &str = "password";
const KEY_PASSPHRASE: &str = "passphrase";

pub struct SettingsService {
settings: Settings,
Expand All @@ -29,13 +29,14 @@ impl SettingsService {
pub fn load(&self) -> Result<HotspotSettings> {
Ok(HotspotSettings {
ssid: self.settings.string(KEY_SSID).to_string(),
password: self.settings.string(KEY_PASSWORD).to_string(),
passphrase: self.settings.string(KEY_PASSPHRASE).to_string(),
})
}
pub fn save(&self, settings: &HotspotSettings) -> Result<()> {
self.settings.set_string(KEY_SSID, &settings.ssid)?;

self.settings.set_string(KEY_PASSWORD, &settings.password)?;
self.settings
.set_string(KEY_PASSPHRASE, &settings.passphrase)?;

Ok(())
}
Expand Down
30 changes: 0 additions & 30 deletions src/tray/menu.rs

This file was deleted.

Loading
Loading