diff --git a/src/main.rs b/src/main.rs index c11bcdb..cc4464d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,43 +1,29 @@ slint::slint!(); slint::include_modules!(); -use reqwest; -use serde_json::Value; -use slint::ToSharedString; +pub mod utils; fn main() { let app: MainWindow = MainWindow::new().unwrap(); - let othertoolmodulecallbacks = app.global::(); + let usermodulecallbacks: UserModuleCallbacks<'_> = app.global::(); + usermodulecallbacks.on_searchUser({ + move || { + utils::usermodules::username_search(); + } + }); + let computermodulecallbacks: ComputerModuleCallbacks<'_> = + app.global::(); + let othertoolmodulecallbacks: OtherToolCallbacks<'_> = app.global::(); + othertoolmodulecallbacks.on_killCherwell({ + move || { + utils::othertoolmodules::kill_cherwell(); + } + }); othertoolmodulecallbacks.on_ipapi({ let app_weak = app.as_weak(); move || { - let app = app_weak.unwrap(); - let mut url = String::from("http://ip-api.com/json/"); - url.push_str(&app.global::().get_ipaddressbar()); - let resp: String = reqwest::blocking::get(url) - .unwrap() - .text() - .ok() - .unwrap() - .into(); - let apitest = geolocateapi(&resp); - let isp = apitest["isp"].to_shared_string(); - let country = apitest["country"].to_shared_string(); - let region = apitest["regionName"].to_shared_string(); - let city = apitest["city"].to_shared_string(); - app.global::() - .set_isp(slint::SharedString::from(isp)); - app.global::() - .set_country(slint::SharedString::from(country)); - app.global::() - .set_state(slint::SharedString::from(region)); - app.global::() - .set_city(slint::SharedString::from(city)); + let app: MainWindow = app_weak.unwrap(); + utils::othertoolmodules::ip_gelocate_api(app); } }); app.run().unwrap(); } - -fn geolocateapi(data: &String) -> Value { - let parsed: Value = serde_json::from_str(data).unwrap(); - return (parsed).clone(); -} diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..aa2f789 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,3 @@ +pub mod othertoolmodules; +pub mod computermodules; +pub mod usermodules; \ No newline at end of file diff --git a/src/utils/computermodules.rs b/src/utils/computermodules.rs new file mode 100644 index 0000000..261cddf --- /dev/null +++ b/src/utils/computermodules.rs @@ -0,0 +1,23 @@ +pub fn computer_file_explorer() { + println!("Test"); +} + +pub fn current_logged_on_user() { + println!("Test"); +} + +pub fn laps_password_viewer() { + println!("Test"); +} + +pub fn remote_to_computer() { + println!("Test"); +} + +pub fn reboot_with_remote() { + println!("Test"); +} + +pub fn sccm_log_parse() { + println!("Test"); +} \ No newline at end of file diff --git a/src/utils/othertoolmodules.rs b/src/utils/othertoolmodules.rs new file mode 100644 index 0000000..8b62e8e --- /dev/null +++ b/src/utils/othertoolmodules.rs @@ -0,0 +1,32 @@ +use crate::{MainWindow, OtherToolCallbacks}; +use reqwest; +use serde_json::Value; +use slint::{ComponentHandle, ToSharedString}; + +pub fn kill_cherwell() { + println!("Test"); +} + +pub fn ip_gelocate_api(app: MainWindow) { + let mut url: String = String::from("http://ip-api.com/json/"); + url.push_str(&app.global::().get_ipaddressbar()); + let resp: String = reqwest::blocking::get(url) + .unwrap() + .text() + .ok() + .unwrap() + .into(); + let parsed: Value = serde_json::from_str(&resp).unwrap(); + let isp: slint::SharedString = parsed["isp"].to_shared_string(); + let country: slint::SharedString = parsed["country"].to_shared_string(); + let region: slint::SharedString = parsed["regionName"].to_shared_string(); + let city: slint::SharedString = parsed["city"].to_shared_string(); + app.global::() + .set_isp(slint::SharedString::from(isp)); + app.global::() + .set_country(slint::SharedString::from(country)); + app.global::() + .set_state(slint::SharedString::from(region)); + app.global::() + .set_city(slint::SharedString::from(city)); +} diff --git a/src/utils/usermodules.rs b/src/utils/usermodules.rs new file mode 100644 index 0000000..6e1aa12 --- /dev/null +++ b/src/utils/usermodules.rs @@ -0,0 +1,7 @@ +pub fn username_search() { + println!("Test"); +} + +pub fn lastname_search() { + println!("Test"); +} \ No newline at end of file