diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..908e9e4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "rust-analyzer.cargo.features": [ + "friends" + ] +} \ No newline at end of file diff --git a/rnex-core/src/nex/friends_handler.rs b/rnex-core/src/nex/friends_handler.rs index 897ff38..3af6ff6 100644 --- a/rnex-core/src/nex/friends_handler.rs +++ b/rnex-core/src/nex/friends_handler.rs @@ -320,6 +320,26 @@ impl Friends for FriendsUser { async fn check_setting_status(&self) -> Result { Ok(0xFF) } + + async fn update_preference(&self, preference: PrincipalPreference) -> Result<(),ErrorCode> { + info!("user updated preference: {:?}", preference); + let any_presence: Any = Any::new(&preference).expect("out of memory"); + + let users = self.fm.users.read().await; + for u in users.deref().iter().filter_map(|u| u.upgrade()) { + info!("sending preference update"); + u.remote + .process_nintendo_notification_event_2(NintendoNotificationEvent { + event_type: 23, + sender: self.pid, + data: any_presence.clone(), + }) + .await; + } + drop(users); + + Ok(()) + } } type HMacMd5 = hmac::Hmac; diff --git a/rnex-core/src/rmc/protocols/friends.rs b/rnex-core/src/rmc/protocols/friends.rs index 98fa501..d25ea9e 100644 --- a/rnex-core/src/rmc/protocols/friends.rs +++ b/rnex-core/src/rmc/protocols/friends.rs @@ -67,7 +67,7 @@ pub struct NintendoPresenceV2 { pub unk6: u8, pub unk7: u8, } -#[derive(RmcSerialize)] +#[derive(RmcSerialize, Clone, Debug)] #[rmc_struct(0)] pub struct PrincipalPreference { #[extends] @@ -171,6 +171,8 @@ pub trait Friends { >; #[method_id(13)] async fn update_presence(&self, presence: NintendoPresenceV2) -> Result<(), ErrorCode>; + #[method_id(16)] + async fn update_preference(&self, preference: PrincipalPreference) -> Result<(), ErrorCode>; #[method_id(18)] async fn delete_persistent_notification( &self,