Added error handling in Geolocate API
This commit is contained in:
Generated
+186
-8
@@ -34,7 +34,7 @@ dependencies = [
|
||||
"accesskit_consumer",
|
||||
"atspi-common",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
"zvariant",
|
||||
]
|
||||
|
||||
@@ -171,7 +171,7 @@ dependencies = [
|
||||
"ndk-context",
|
||||
"ndk-sys",
|
||||
"num_enum",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -629,7 +629,7 @@ dependencies = [
|
||||
"polling",
|
||||
"rustix",
|
||||
"slab",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -710,8 +710,10 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"reqwest",
|
||||
"serde_json",
|
||||
"simple-ldap",
|
||||
"slint",
|
||||
"slint-build",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1065,6 +1067,24 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a"
|
||||
|
||||
[[package]]
|
||||
name = "deadpool"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb84100978c1c7b37f09ed3ce3e5f843af02c2a2c431bae5b19230dad2c1b490"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"deadpool-runtime",
|
||||
"num_cpus",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deadpool-runtime"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "092966b41edc516079bdf31ec78a2e0588d1d0c08f78b91d8307215928642b2b"
|
||||
|
||||
[[package]]
|
||||
name = "derive_more"
|
||||
version = "1.0.0"
|
||||
@@ -2510,7 +2530,7 @@ dependencies = [
|
||||
"combine",
|
||||
"jni-sys",
|
||||
"log",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
"walkdir",
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
@@ -2583,6 +2603,40 @@ version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "lber"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2df7f9fd9f64cf8f59e1a4a0753fe7d575a5b38d3d7ac5758dcee9357d83ef0a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ldap3"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "166199a8207874a275144c8a94ff6eed5fcbf5c52303e4d9b4d53a0c7ac76554"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"lazy_static",
|
||||
"lber",
|
||||
"log",
|
||||
"native-tls",
|
||||
"nom",
|
||||
"percent-encoding",
|
||||
"thiserror 1.0.69",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tokio-stream",
|
||||
"tokio-util",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.2"
|
||||
@@ -2674,6 +2728,16 @@ version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.25"
|
||||
@@ -2703,7 +2767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ca94c7bf1e2557c2798989c43416822c12fc5dcc5e17cc3307ef0e71894a955"
|
||||
dependencies = [
|
||||
"lyon_path",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2822,7 +2886,7 @@ dependencies = [
|
||||
"ndk-sys",
|
||||
"num_enum",
|
||||
"raw-window-handle",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2873,6 +2937,16 @@ dependencies = [
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
|
||||
dependencies = [
|
||||
"hermit-abi 0.3.9",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_enum"
|
||||
version = "0.7.3"
|
||||
@@ -3198,6 +3272,15 @@ dependencies = [
|
||||
"libredox",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-float"
|
||||
version = "2.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ordered-stream"
|
||||
version = "0.2.0"
|
||||
@@ -3223,6 +3306,29 @@ version = "2.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.9.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"redox_syscall 0.5.8",
|
||||
"smallvec",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
@@ -3850,6 +3956,16 @@ dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde-value"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
|
||||
dependencies = [
|
||||
"ordered-float",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.217"
|
||||
@@ -3937,6 +4053,23 @@ version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "simple-ldap"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a44f48965194c331276aef5f7328bf4d30d64113289c1211fddade9968166d56"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"deadpool",
|
||||
"futures",
|
||||
"ldap3",
|
||||
"log",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_json",
|
||||
"thiserror 2.0.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simplecss"
|
||||
version = "0.2.2"
|
||||
@@ -4063,7 +4196,7 @@ dependencies = [
|
||||
"log",
|
||||
"memmap2",
|
||||
"rustix",
|
||||
"thiserror",
|
||||
"thiserror 1.0.69",
|
||||
"wayland-backend",
|
||||
"wayland-client",
|
||||
"wayland-csd-frame",
|
||||
@@ -4326,7 +4459,16 @@ version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
"thiserror-impl 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc"
|
||||
dependencies = [
|
||||
"thiserror-impl 2.0.11",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4340,6 +4482,17 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiff"
|
||||
version = "0.9.1"
|
||||
@@ -4425,11 +4578,25 @@ dependencies = [
|
||||
"bytes",
|
||||
"libc",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"socket2",
|
||||
"tokio-macros",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-macros"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.1"
|
||||
@@ -4450,6 +4617,17 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-stream"
|
||||
version = "0.1.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"pin-project-lite",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.13"
|
||||
|
||||
@@ -6,7 +6,9 @@ edition = "2021"
|
||||
[dependencies]
|
||||
reqwest = { version = "0.12.12", features = ["blocking"] }
|
||||
serde_json = "1.0.137"
|
||||
simple-ldap = "2.1.1"
|
||||
slint = "1.9.2"
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
|
||||
[build-dependencies]
|
||||
slint-build = "1.9.2"
|
||||
|
||||
@@ -10,23 +10,33 @@ pub fn kill_cherwell() {
|
||||
pub fn ip_gelocate_api(app: MainWindow) {
|
||||
let mut url: String = String::from("http://ip-api.com/json/");
|
||||
url.push_str(&app.global::<OtherToolCallbacks>().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::<OtherToolCallbacks>()
|
||||
.set_isp(slint::SharedString::from(isp));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_country(slint::SharedString::from(country));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_state(slint::SharedString::from(region));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_city(slint::SharedString::from(city));
|
||||
let resp: Result<reqwest::blocking::Response, reqwest::Error> = reqwest::blocking::get(url);
|
||||
match &resp {
|
||||
Err(_e) => {
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_isp(slint::SharedString::from("Failed to resolve IP/URL"));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_country(slint::SharedString::from("Failed to resolve IP/URL"));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_state(slint::SharedString::from("Failed to resolve IP/URL"));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_city(slint::SharedString::from("Failed to resolve IP/URL"));
|
||||
}
|
||||
Ok(_t) => {
|
||||
let result: String = resp.unwrap().text().unwrap().into();
|
||||
let parsed: Value = serde_json::from_str(&result).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::<OtherToolCallbacks>()
|
||||
.set_isp(slint::SharedString::from(isp));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_country(slint::SharedString::from(country));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_state(slint::SharedString::from(region));
|
||||
app.global::<OtherToolCallbacks>()
|
||||
.set_city(slint::SharedString::from(city));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { AboutSlint, VerticalBox, GridBox, Button, LineEdit, HorizontalBox, TextEdit, SpinBox } from "std-widgets.slint";
|
||||
|
||||
export global ComputerModuleCallbacks {
|
||||
pure callback killCherwell();
|
||||
}
|
||||
|
||||
export component ComputerModules inherits Window {
|
||||
VerticalLayout {
|
||||
spacing: 5px;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { AboutSlint, VerticalBox, GridBox, Button, LineEdit, HorizontalBox, TextEdit, SpinBox, StandardListView } from "std-widgets.slint";
|
||||
|
||||
export global UserModuleCallbacks {
|
||||
pure callback searchUser();
|
||||
}
|
||||
|
||||
export component UserModules inherits Window {
|
||||
VerticalLayout {
|
||||
spacing: 5px;
|
||||
@@ -29,6 +33,9 @@ export component UserModules inherits Window {
|
||||
Button {
|
||||
text: "Search";
|
||||
primary: true;
|
||||
clicked => {
|
||||
UserModuleCallbacks.searchUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import { ComputerModules } from "pages/computermodules.slint";
|
||||
import { OtherTools } from "pages/othertools.slint";
|
||||
import { SettingsModules } from "pages/settings.slint";
|
||||
import { SideBar } from "sidebar.slint";
|
||||
export { UserModuleCallbacks } from "pages/usermodules.slint";
|
||||
export { ComputerModuleCallbacks } from "pages/computermodules.slint";
|
||||
export { OtherToolCallbacks } from "pages/othertools.slint";
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
|
||||
Reference in New Issue
Block a user