Merge branch 'v0' of https://git.virintox.com/spfn/rust-nex into super-mario-maker
This commit is contained in:
commit
08f014fe39
12 changed files with 406 additions and 151 deletions
|
|
@ -2,9 +2,13 @@ use macros::{RmcSerialize, method_id, rmc_proto};
|
|||
|
||||
use rnex_core::{kerberos::KerberosDateTime, rmc::response::ErrorCode};
|
||||
|
||||
use rnex_core::rmc::structures::{data::Data, rmc_struct};
|
||||
|
||||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct MiiV2 {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub name: String,
|
||||
pub unk: u8,
|
||||
pub unk2: u8,
|
||||
|
|
@ -15,6 +19,8 @@ pub struct MiiV2 {
|
|||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct PrincipalBasicInfo {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub pid: u32,
|
||||
pub nnid: String,
|
||||
pub mii: MiiV2,
|
||||
|
|
@ -24,21 +30,27 @@ pub struct PrincipalBasicInfo {
|
|||
#[derive(RmcSerialize, Debug, Clone)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct NNAInfo {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub principal_basic_info: PrincipalBasicInfo,
|
||||
pub unk: u8,
|
||||
pub unk2: u8,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[derive(RmcSerialize, Clone, Copy, Debug)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct GameKey {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub tid: u64,
|
||||
pub version: u16,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[derive(RmcSerialize, Clone, Debug)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct NintendoPresenceV2 {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub changed_flags: u32,
|
||||
pub is_online: bool,
|
||||
pub game_key: GameKey,
|
||||
|
|
@ -58,6 +70,8 @@ pub struct NintendoPresenceV2 {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct PrincipalPreference {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub show_online: bool,
|
||||
pub show_playing_title: bool,
|
||||
pub block_friend_request: bool,
|
||||
|
|
@ -66,6 +80,8 @@ pub struct PrincipalPreference {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct Comment {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub unk: u8,
|
||||
pub message: String,
|
||||
pub last_changed: KerberosDateTime,
|
||||
|
|
@ -74,6 +90,8 @@ pub struct Comment {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct FriendInfo {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub nna_info: NNAInfo,
|
||||
pub presence: NintendoPresenceV2,
|
||||
pub comment: Comment,
|
||||
|
|
@ -85,6 +103,8 @@ pub struct FriendInfo {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct FriendRequestMessage {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub friend_request_id: u64,
|
||||
pub is_recieved: u8,
|
||||
pub unk: u8,
|
||||
|
|
@ -99,6 +119,8 @@ pub struct FriendRequestMessage {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct FriendRequest {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub basic_info: PrincipalBasicInfo,
|
||||
pub request_message: FriendRequestMessage,
|
||||
pub sent_on: KerberosDateTime,
|
||||
|
|
@ -107,6 +129,8 @@ pub struct FriendRequest {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct BlacklistedPrincipal {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub basic_info: PrincipalBasicInfo,
|
||||
pub game_key: GameKey,
|
||||
pub since: KerberosDateTime,
|
||||
|
|
@ -114,6 +138,8 @@ pub struct BlacklistedPrincipal {
|
|||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct PersistentNotification {
|
||||
#[extends]
|
||||
pub data: Data,
|
||||
pub unk1: u64,
|
||||
pub unk2: u32,
|
||||
pub unk3: u32,
|
||||
|
|
@ -143,6 +169,13 @@ pub trait Friends {
|
|||
),
|
||||
ErrorCode,
|
||||
>;
|
||||
#[method_id(13)]
|
||||
async fn update_presence(&self, presence: NintendoPresenceV2) -> Result<(), ErrorCode>;
|
||||
#[method_id(18)]
|
||||
async fn delete_persistent_notification(
|
||||
&self,
|
||||
notifs: Vec<PersistentNotification>,
|
||||
) -> Result<(), ErrorCode>;
|
||||
#[method_id(19)]
|
||||
async fn check_setting_status(&self) -> Result<u8, ErrorCode>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ pub mod matchmake;
|
|||
pub mod matchmake_ext;
|
||||
pub mod matchmake_extension;
|
||||
pub mod nat_traversal;
|
||||
pub mod nintendo_notification;
|
||||
pub mod notifications;
|
||||
pub mod ranking;
|
||||
pub mod secure;
|
||||
|
|
|
|||
39
rnex-core/src/rmc/protocols/nintendo_notification.rs
Normal file
39
rnex-core/src/rmc/protocols/nintendo_notification.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
use macros::{RmcSerialize, method_id, rmc_proto};
|
||||
|
||||
use rnex_core::PID;
|
||||
use rnex_core::rmc::structures::any::Any;
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct NintendoNotificationEvent {
|
||||
pub event_type: u32,
|
||||
pub sender: PID,
|
||||
pub data: Any,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct NintendoNotificationEventGeneral {
|
||||
pub param1: u32,
|
||||
pub param2: u64,
|
||||
pub param3: u64,
|
||||
pub str_param: String,
|
||||
}
|
||||
|
||||
#[derive(RmcSerialize)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct NintendoNotificationEventProfile {
|
||||
pub region: u8,
|
||||
pub country: u8,
|
||||
pub area: u8,
|
||||
pub language: u8,
|
||||
pub platform: u8,
|
||||
}
|
||||
|
||||
#[rmc_proto(100, NoReturn)]
|
||||
pub trait NintendoNotification {
|
||||
#[method_id(1)]
|
||||
async fn process_nintendo_notification_event_1(&self, notif: NintendoNotificationEvent);
|
||||
#[method_id(2)]
|
||||
async fn process_nintendo_notification_event_2(&self, notif: NintendoNotificationEvent);
|
||||
}
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
use rnex_core::rmc::structures::{Result, RmcSerialize};
|
||||
use std::io::{Read, Write};
|
||||
use std::io::{Cursor, Read, Write};
|
||||
use v_byte_helpers::{IS_BIG_ENDIAN, ReadExtensions};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct Any {
|
||||
pub name: String,
|
||||
pub data: Vec<u8>,
|
||||
|
|
@ -13,10 +13,7 @@ impl RmcSerialize for Any {
|
|||
self.name.serialize(writer)?;
|
||||
|
||||
let u32_len = self.data.len() as u32;
|
||||
|
||||
u32_len.serialize(writer)?;
|
||||
u32_len.serialize(writer)?;
|
||||
|
||||
(u32_len + 4).serialize(writer)?;
|
||||
self.data.serialize(writer)?;
|
||||
|
||||
Ok(())
|
||||
|
|
@ -26,12 +23,23 @@ impl RmcSerialize for Any {
|
|||
|
||||
// also length ?
|
||||
let _len2: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
let length: u32 = reader.read_struct(IS_BIG_ENDIAN)?;
|
||||
|
||||
let mut data = vec![0; length as usize];
|
||||
|
||||
reader.read_exact(&mut data)?;
|
||||
let data = Vec::deserialize(reader)?;
|
||||
|
||||
Ok(Any { name, data })
|
||||
}
|
||||
}
|
||||
|
||||
impl Any {
|
||||
pub fn try_get<T: RmcSerialize>(&self) -> Option<Result<T>> {
|
||||
if self.name != T::name() {
|
||||
return None;
|
||||
}
|
||||
return Some(T::deserialize(&mut Cursor::new(&self.data[..])));
|
||||
}
|
||||
pub fn new<T: RmcSerialize>(val: &T) -> Result<Self> {
|
||||
return Ok(Self {
|
||||
name: T::name().to_owned(),
|
||||
data: val.to_data()?,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
5
rnex-core/src/rmc/structures/data.rs
Normal file
5
rnex-core/src/rmc/structures/data.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
use macros::RmcSerialize;
|
||||
|
||||
#[derive(RmcSerialize, Debug, Clone, Copy)]
|
||||
#[rmc_struct(0)]
|
||||
pub struct Data {}
|
||||
|
|
@ -26,6 +26,7 @@ pub type Result<T> = std::result::Result<T, Error>;
|
|||
pub mod any;
|
||||
pub mod buffer;
|
||||
pub mod connection_data;
|
||||
pub mod data;
|
||||
pub mod helpers;
|
||||
pub mod list;
|
||||
pub mod matchmake;
|
||||
|
|
@ -62,6 +63,9 @@ pub trait RmcSerialize {
|
|||
|
||||
Ok(data)
|
||||
}
|
||||
fn name() -> &'static str {
|
||||
"NoNameSpecified"
|
||||
}
|
||||
}
|
||||
|
||||
impl RmcSerialize for () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue