Big refactor, file change notifications added

This commit is contained in:
Your Name
2023-02-22 22:44:11 -05:00
parent 45f8d9bd26
commit 60b7b34708
6 changed files with 199 additions and 64 deletions

View File

@@ -6,9 +6,13 @@ use windows::{
},
};
pub trait DeviceNotificationObserver {
fn add_device(&self, device_id : &windows::core::PCWSTR);
}
#[windows::core::implement(IMMNotificationClient)]
pub(crate) struct DeviceNotificationClient {
pub(crate) callback: Box<dyn Fn(&windows::core::PCWSTR)>
pub observer: Box<dyn DeviceNotificationObserver>
}
impl IMMNotificationClient_Impl for DeviceNotificationClient {
@@ -21,7 +25,7 @@ impl IMMNotificationClient_Impl for DeviceNotificationClient {
}
fn OnDeviceAdded(&self, pwstrdeviceid: &windows::core::PCWSTR) -> windows::core::Result<()> {
(self.callback)(pwstrdeviceid);
self.observer.add_device(pwstrdeviceid);
Ok(())
}