Skip to content

Commit

Permalink
minor version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
kaii-lb committed Mar 24, 2024
1 parent 73806b9 commit abcb82a
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 171 deletions.
335 changes: 178 additions & 157 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "overskride"
version = "0.5.6"
version = "0.5.7"
edition = "2021"
authors = ["kaii_lb <[email protected]"]

Expand Down
3 changes: 2 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
project('overskride', 'rust',
version: '0.5.6',
version: '0.5.7',
meson_version: '>= 0.62.0',
default_options : 'prefix=/usr',
default_options: [ 'warning_level=2', 'werror=false', ],
)

Expand Down
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub static VERSION: &str = "0.5.6";
pub static VERSION: &str = "0.5.7";
pub static GETTEXT_PACKAGE: &str = "overskride";
pub static LOCALEDIR: &str = "/usr/share/locale";
pub static PKGDATADIR: &str = "/usr/share/overskride";
2 changes: 1 addition & 1 deletion src/gtk/connected-switch-row.blp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ template $ConnectedSwitchRow : Adw.ActionRow {
Switch switch {
// active: true;
valign: center;
can-focus: false;
//can-focus: false;
}
}
}
23 changes: 23 additions & 0 deletions src/gtk/preferences-page.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Gtk 4.0;
using Adw 1;

Adw.PreferencesWindow pref_window {
default-width: 600;
default-height: 500;
title: _("Preferences");

Adw.PreferencesPage {
title: _("Behavior");
icon-name: "settings-symbolic";

Adw.PreferencesGroup {
title: _("Sharing Settings");
description: _("Change how the app behaves during file transfers.");

Adw.SwitchRow auto_accept_after_first_row {
title: _("Auto Accept After First File");
subtitle: _("when receiving files, auto accept every file after the first one");
}
}
}
}
23 changes: 15 additions & 8 deletions src/obex/obex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static mut OUTBOUND: bool = false;
static mut LAST_BYTES: u64 = 0;
pub static mut BREAKING: bool = false;
pub static mut CANCEL: bool = false;
pub static mut AUTO_ACCEPT_AFTER_FIRST: bool = true;

// fn approx_equal(a: f32, b: f32, decimal_places: u8) -> bool {
// let factor = 10.0f32.powi(decimal_places as i32);
Expand Down Expand Up @@ -92,7 +93,7 @@ fn handle_properties_updated(interface: String, changed_properties: PropMap, tra

// calculate the transfer speed by subtracting the current amount from the last
let value_kb = unsafe {
println!("transferred: {}, last: {}", transferred.unwrap(), LAST_BYTES);
// println!("transferred: {}, last: {}", transferred.unwrap(), LAST_BYTES);
(transferred.unwrap_or(0) / 1000).saturating_sub(LAST_BYTES / 1000)
};

Expand Down Expand Up @@ -134,11 +135,15 @@ fn handle_interface_added(path: &Path, interfaces: &HashMap<String, PropMap>) {
}
}
// if the interface is a transfer then handle the properties updated signal
else if interface.0 == TRANSFER_INTERFACE && path.contains("server") && path.contains("transfer"){
else if interface.0 == TRANSFER_INTERFACE && path.contains("server") && path.contains("transfer") {
let conn: &mut Connection;
unsafe {
conn = SESSION_BUS.get_mut().unwrap().as_mut().unwrap();
CURRENT_TRANSFER = path.clone().to_string();
if CURRENT_TRANSFER != path.to_string() {
CONFIRMATION_AUTHORIZATION = false
}

CURRENT_TRANSFER = path.to_string();
println!("path is {}", path);
}
let proxy = conn.with_proxy("org.bluez.obex", path, Duration::from_millis(1000));
Expand Down Expand Up @@ -263,7 +268,7 @@ fn create_agent(cr: &mut Crossroads, sender: Sender<Message>) {
}
let mb = ((filesize as f32 / 1000000.0) * 100.0).round() / 100.0; // to megabytes

// get the target device, if it doesn't exist panic ensues
// get the target device, if it doesn't exist, panic ensues
let sender_props = conn.with_proxy("org.bluez.obex", session, std::time::Duration::from_secs(5)).get_all(SESSION_INTERFACE).unwrap();
let device = sender_props.get("Destination").expect("cannot get sender device").0.as_str().unwrap_or("00:00:00:00:00:00");

Expand All @@ -290,12 +295,14 @@ fn create_agent(cr: &mut Crossroads, sender: Sender<Message>) {
}

// spawn a dialog returning the accepted bool, no accepted => reject transfer
if spawn_dialog(filename.clone(), &sender, device_name) {
if unsafe { CONFIRMATION_AUTHORIZATION } || spawn_dialog(filename.clone(), &sender, device_name) {
println!("transfer is: {:?}", transfer);
sender.send(Message::StartTransfer(transfer.to_string(), filename.clone(), 0.0, 0.0, mb, false)).expect("cannot send message");

unsafe {
CONFIRMATION_AUTHORIZATION = false;
if !AUTO_ACCEPT_AFTER_FIRST {
CONFIRMATION_AUTHORIZATION = false;
}
}

Ok((filename,))
Expand Down Expand Up @@ -329,9 +336,9 @@ fn create_agent(cr: &mut Crossroads, sender: Sender<Message>) {
Ok(())
});
});
println!("created obex agent");

cr.insert("/overskride/agent", &[agent], ());

println!("created obex agent");
}

/// Spawns a new dialog asking the user to allow or reject a file transfer from a device
Expand Down
8 changes: 6 additions & 2 deletions src/widgets/connected_switch_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use gtk::prelude::ObjectExt;
use std::cell::RefCell;

mod imp {
use gtk::prelude::WidgetExt;

use super::*;

/// an adw::SwitchRow but with the ability to show a spinning icon next to it
Expand Down Expand Up @@ -47,6 +49,9 @@ mod imp {
impl ObjectImpl for ConnectedSwitchRow {
fn constructed(&self) {
self.parent_constructed();
self.switch.get().connect_activate(|meeee| {
meeee.parent().unwrap().activate();
});
}
}

Expand Down Expand Up @@ -83,7 +88,6 @@ mod imp {
self.switch.set_active(active);
*self.active.borrow_mut() = active;
}

}
}

Expand All @@ -98,7 +102,7 @@ impl ConnectedSwitchRow {
pub fn new() -> Self {
Object::builder()
.build()
}
}
}

impl Default for ConnectedSwitchRow {
Expand Down

0 comments on commit abcb82a

Please sign in to comment.