diff --git a/.idea/workspace.xml b/.idea/workspace.xml index fac69d5..f28b1c5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -8,17 +8,35 @@ + + + + - - - + + + + + + + + + + + + + @@ -29,30 +47,40 @@ "associatedIndex": 8 } + + + - - + - + + + + + + + @@ -117,10 +145,15 @@ + + + + \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index a3e7063..f1c2945 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,11 +6,19 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] name = "pika_unixsocket_tools" -path = "src/pika_unixsocket_tools/lib.rs" +path = "src/lib/lib.rs" + +[[bin]] +name = "pika-idk-manager" +path = "src/bin/gui/main.rs" [[bin]] name = "apt_update" -path = "src/apt_update/main.rs" +path = "src/bin/apt/apt_update/main.rs" + +[[bin]] +name = "apt_full_upgrade" +path = "src/bin/apt/apt_full_upgrade/main.rs" [dependencies] adw = { version = "0.6.0", package = "libadwaita", features = ["v1_4"] } diff --git a/src/bin/apt/apt_full_upgrade/main.rs b/src/bin/apt/apt_full_upgrade/main.rs new file mode 100644 index 0000000..e71fdf5 --- /dev/null +++ b/src/bin/apt/apt_full_upgrade/main.rs @@ -0,0 +1 @@ +fn main() {} \ No newline at end of file diff --git a/src/bin/apt/apt_update/main.rs b/src/bin/apt/apt_update/main.rs new file mode 100644 index 0000000..33e99f0 --- /dev/null +++ b/src/bin/apt/apt_update/main.rs @@ -0,0 +1,34 @@ +use rust_apt::new_cache; +use rust_apt::progress::{AcquireProgress, DynAcquireProgress}; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tokio::runtime::Runtime; +use pika_unixsocket_tools::apt_update_progress_socket::AptUpdateProgressSocket; +use pika_unixsocket_tools::pika_unixsocket_tools::*; + +fn main() { + let update_cache = new_cache!().unwrap(); + let percent_socket_path = "/tmp/pika_apt_update_percent.sock"; + let status_socket_path = "/tmp/pika_apt_update_status.sock"; + match update_cache.update(&mut AcquireProgress::new(AptUpdateProgressSocket::new( + percent_socket_path, + status_socket_path, + ))) { + Ok(_) => { + Runtime::new() + .unwrap() + .block_on(send_successful_to_socket(percent_socket_path)); + Runtime::new() + .unwrap() + .block_on(send_successful_to_socket(status_socket_path)); + } + Err(e) => { + Runtime::new() + .unwrap() + .block_on(send_failed_to_socket(percent_socket_path)); + Runtime::new() + .unwrap() + .block_on(send_failed_to_socket(status_socket_path)); + panic!("{}", e.to_string()) + } + }; +} \ No newline at end of file diff --git a/src/apt_package_row/imp.rs b/src/bin/gui/apt_package_row/imp.rs similarity index 100% rename from src/apt_package_row/imp.rs rename to src/bin/gui/apt_package_row/imp.rs diff --git a/src/apt_package_row/mod.rs b/src/bin/gui/apt_package_row/mod.rs similarity index 100% rename from src/apt_package_row/mod.rs rename to src/bin/gui/apt_package_row/mod.rs diff --git a/src/apt_update_page/mod.rs b/src/bin/gui/apt_update_page/mod.rs similarity index 99% rename from src/apt_update_page/mod.rs rename to src/bin/gui/apt_update_page/mod.rs index df21a8d..6d94f4a 100644 --- a/src/apt_update_page/mod.rs +++ b/src/bin/gui/apt_update_page/mod.rs @@ -1,12 +1,12 @@ mod process; +use pika_unixsocket_tools::pika_unixsocket_tools::*; use crate::apt_package_row::AptPackageRow; use adw::gio::{Action, SimpleAction}; use adw::prelude::*; use adw::ActionRow; use gtk::glib::*; use gtk::*; -use pika_unixsocket_tools::*; use rust_apt::cache::*; use rust_apt::new_cache; use rust_apt::records::RecordField; diff --git a/src/apt_update_page/process.rs b/src/bin/gui/apt_update_page/process.rs similarity index 100% rename from src/apt_update_page/process.rs rename to src/bin/gui/apt_update_page/process.rs diff --git a/src/build_ui/mod.rs b/src/bin/gui/build_ui/mod.rs similarity index 100% rename from src/build_ui/mod.rs rename to src/bin/gui/build_ui/mod.rs diff --git a/src/config.rs b/src/bin/gui/config.rs similarity index 100% rename from src/config.rs rename to src/bin/gui/config.rs diff --git a/src/main.rs b/src/bin/gui/main.rs similarity index 100% rename from src/main.rs rename to src/bin/gui/main.rs diff --git a/src/style.css b/src/bin/gui/style.css similarity index 100% rename from src/style.css rename to src/bin/gui/style.css diff --git a/src/apt_update/main.rs b/src/lib/apt_update_progress_socket/mod.rs similarity index 82% rename from src/apt_update/main.rs rename to src/lib/apt_update_progress_socket/mod.rs index 8f591be..be309e3 100644 --- a/src/apt_update/main.rs +++ b/src/lib/apt_update_progress_socket/mod.rs @@ -1,9 +1,8 @@ -use pika_unixsocket_tools::*; -use rust_apt::new_cache; -use rust_apt::progress::{AcquireProgress, DynAcquireProgress}; +use crate::pika_unixsocket_tools::*; +use rust_apt::progress::{DynAcquireProgress}; use rust_apt::raw::{AcqTextStatus, ItemDesc, PkgAcquire}; use std::process::exit; -use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tokio::io::{AsyncWriteExt}; use tokio::net::UnixStream; use tokio::runtime::Runtime; @@ -129,34 +128,6 @@ impl<'a> DynAcquireProgress for AptUpdateProgressSocket<'a> { } } -fn main() { - let update_cache = new_cache!().unwrap(); - let percent_socket_path = "/tmp/pika_apt_update_percent.sock"; - let status_socket_path = "/tmp/pika_apt_update_status.sock"; - match update_cache.update(&mut AcquireProgress::new(AptUpdateProgressSocket::new( - percent_socket_path, - status_socket_path, - ))) { - Ok(_) => { - Runtime::new() - .unwrap() - .block_on(send_successful_to_socket(percent_socket_path)); - Runtime::new() - .unwrap() - .block_on(send_successful_to_socket(status_socket_path)); - } - Err(e) => { - Runtime::new() - .unwrap() - .block_on(send_failed_to_socket(percent_socket_path)); - Runtime::new() - .unwrap() - .block_on(send_failed_to_socket(status_socket_path)); - panic!("{}", e.to_string()) - } - }; -} - async fn send_progress_percent(progress_f32: f32, socket_path: &str) { // Connect to the Unix socket let mut stream = UnixStream::connect(socket_path) diff --git a/src/lib/lib.rs b/src/lib/lib.rs new file mode 100644 index 0000000..22816ae --- /dev/null +++ b/src/lib/lib.rs @@ -0,0 +1,2 @@ +pub mod pika_unixsocket_tools; +pub mod apt_update_progress_socket; \ No newline at end of file diff --git a/src/pika_unixsocket_tools/lib.rs b/src/lib/pika_unixsocket_tools/mod.rs similarity index 100% rename from src/pika_unixsocket_tools/lib.rs rename to src/lib/pika_unixsocket_tools/mod.rs