Big refactor, file change notifications added
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user