Skip to content

Commit

Permalink
lots of refactors and changes to be included in upcoming 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
F0903 committed Sep 6, 2024
1 parent 8efe173 commit bc52638
Show file tree
Hide file tree
Showing 13 changed files with 562 additions and 293 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore

# CUSTOM PROJECT IGNORES:
config.json

# User-specific files
*.rsuser
*.suo
Expand Down
172 changes: 129 additions & 43 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = ["shared", "notification_provider"]

[workspace.package]
version = "2.0.4"
version = "3.0.0"
edition = "2021"
publish = false
repository = "https://github.com/F0903/AutoPower"
Expand All @@ -28,7 +28,7 @@ codegen-units = 1
[workspace.dependencies]
bincode = "^1.3"
serde = { version = "^1.0", features = ["derive"] }
windows = { version = "^0.52" }
windows = { version = "^0.58" }

[dependencies]
autopower_shared = { path = "shared" }
Expand All @@ -41,3 +41,5 @@ windows = { workspace = true, features = [
"Win32_System_Threading",
"Win32_UI_WindowsAndMessaging",
] }
serde = { workspace = true }
serde_json = "^1.0"
6 changes: 5 additions & 1 deletion notification_provider/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ fn wait_for_input() -> Result<()> {
}

fn run() -> Result<()> {
unsafe { CoInitialize(None).map_err(|e| format!("Could not init COM!\n{}", e))? };
unsafe {
CoInitialize(None)
.ok()
.map_err(|e| format!("Could not init COM!\n{}", e))?
};
wait_for_input().map_err(|e| format!("Error occured while waiting for input!\n{}", e))?;
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions shared/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use windows::{
};

pub fn get_last_win32_err() -> super::Result<String> {
let err = unsafe { GetLastError().unwrap_err() };
let err = unsafe { GetLastError().0 };
const BUF_SIZE: usize = 128;
let buf: PWSTR = PWSTR::from_raw([0; BUF_SIZE + 1].as_mut_ptr());
let count = unsafe {
FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM,
None,
err.code().0 as u32,
err,
0,
buf,
BUF_SIZE as u32,
Expand Down
Loading

0 comments on commit bc52638

Please sign in to comment.