Skip to content

Commit

Permalink
Merge pull request #83 from PretendoNetwork/types-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniElectra authored Jan 12, 2025
2 parents a9e527b + 78a578d commit 0e0d9b6
Show file tree
Hide file tree
Showing 797 changed files with 12,778 additions and 9,110 deletions.
18 changes: 9 additions & 9 deletions aa-user/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ const (
// Protocol stores all the RMC method handlers for the AAUser protocol and listens for requests
type Protocol struct {
endpoint nex.EndpointInterface
RegisterApplication func(err error, packet nex.PacketInterface, callID uint32, titleID *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error)
UnregisterApplication func(err error, packet nex.PacketInterface, callID uint32, titleID *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error)
SetApplicationInfo func(err error, packet nex.PacketInterface, callID uint32, applicationInfo *types.List[*aauser_types.ApplicationInfo]) (*nex.RMCMessage, *nex.Error)
RegisterApplication func(err error, packet nex.PacketInterface, callID uint32, titleID types.UInt64) (*nex.RMCMessage, *nex.Error)
UnregisterApplication func(err error, packet nex.PacketInterface, callID uint32, titleID types.UInt64) (*nex.RMCMessage, *nex.Error)
SetApplicationInfo func(err error, packet nex.PacketInterface, callID uint32, applicationInfo types.List[aauser_types.ApplicationInfo]) (*nex.RMCMessage, *nex.Error)
GetApplicationInfo func(err error, packet nex.PacketInterface, callID uint32) (*nex.RMCMessage, *nex.Error)
Patches nex.ServiceProtocol
PatchedMethods []uint32
Expand All @@ -43,9 +43,9 @@ type Protocol struct {
type Interface interface {
Endpoint() nex.EndpointInterface
SetEndpoint(endpoint nex.EndpointInterface)
SetHandlerRegisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error))
SetHandlerUnregisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error))
SetHandlerSetApplicationInfo(handler func(err error, packet nex.PacketInterface, callID uint32, applicationInfo *types.List[*aauser_types.ApplicationInfo]) (*nex.RMCMessage, *nex.Error))
SetHandlerRegisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID types.UInt64) (*nex.RMCMessage, *nex.Error))
SetHandlerUnregisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID types.UInt64) (*nex.RMCMessage, *nex.Error))
SetHandlerSetApplicationInfo(handler func(err error, packet nex.PacketInterface, callID uint32, applicationInfo types.List[aauser_types.ApplicationInfo]) (*nex.RMCMessage, *nex.Error))
SetHandlerGetApplicationInfo(handler func(err error, packet nex.PacketInterface, callID uint32) (*nex.RMCMessage, *nex.Error))
}

Expand All @@ -60,17 +60,17 @@ func (protocol *Protocol) SetEndpoint(endpoint nex.EndpointInterface) {
}

// SetHandlerRegisterApplication sets the handler for the RegisterApplication method
func (protocol *Protocol) SetHandlerRegisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error)) {
func (protocol *Protocol) SetHandlerRegisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID types.UInt64) (*nex.RMCMessage, *nex.Error)) {
protocol.RegisterApplication = handler
}

// SetHandlerUnregisterApplication sets the handler for the UnregisterApplication method
func (protocol *Protocol) SetHandlerUnregisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID *types.PrimitiveU64) (*nex.RMCMessage, *nex.Error)) {
func (protocol *Protocol) SetHandlerUnregisterApplication(handler func(err error, packet nex.PacketInterface, callID uint32, titleID types.UInt64) (*nex.RMCMessage, *nex.Error)) {
protocol.UnregisterApplication = handler
}

// SetHandlerSetApplicationInfo sets the handler for the SetApplicationInfo method
func (protocol *Protocol) SetHandlerSetApplicationInfo(handler func(err error, packet nex.PacketInterface, callID uint32, applicationInfo *types.List[*aauser_types.ApplicationInfo]) (*nex.RMCMessage, *nex.Error)) {
func (protocol *Protocol) SetHandlerSetApplicationInfo(handler func(err error, packet nex.PacketInterface, callID uint32, applicationInfo types.List[aauser_types.ApplicationInfo]) (*nex.RMCMessage, *nex.Error)) {
protocol.SetApplicationInfo = handler
}

Expand Down
4 changes: 2 additions & 2 deletions aa-user/register_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func (protocol *Protocol) handleRegisterApplication(packet nex.PacketInterface)
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

titleID := types.NewPrimitiveU64(0)
var titleID types.UInt64

err := titleID.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.RegisterApplication(fmt.Errorf("Failed to read titleID from parameters. %s", err.Error()), packet, callID, nil)
_, rmcError := protocol.RegisterApplication(fmt.Errorf("Failed to read titleID from parameters. %s", err.Error()), packet, callID, titleID)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
5 changes: 2 additions & 3 deletions aa-user/set_application_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ func (protocol *Protocol) handleSetApplicationInfo(packet nex.PacketInterface) {
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

applicationInfo := types.NewList[*aauser_types.ApplicationInfo]()
applicationInfo.Type = aauser_types.NewApplicationInfo()
var applicationInfo types.List[aauser_types.ApplicationInfo]

err := applicationInfo.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.SetApplicationInfo(fmt.Errorf("Failed to read applicationInfo from parameters. %s", err.Error()), packet, callID, nil)
_, rmcError := protocol.SetApplicationInfo(fmt.Errorf("Failed to read applicationInfo from parameters. %s", err.Error()), packet, callID, applicationInfo)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
48 changes: 31 additions & 17 deletions aa-user/types/application_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
// ApplicationInfo is a type within the AAUser protocol
type ApplicationInfo struct {
types.Structure
*types.Data
TitleID *types.PrimitiveU64
TitleVersion *types.PrimitiveU16
types.Data
TitleID types.UInt64
TitleVersion types.UInt16
}

// WriteTo writes the ApplicationInfo to the given writable
func (ai *ApplicationInfo) WriteTo(writable types.Writable) {
func (ai ApplicationInfo) WriteTo(writable types.Writable) {
ai.Data.WriteTo(writable)

contentWritable := writable.CopyNew()
Expand Down Expand Up @@ -60,24 +60,24 @@ func (ai *ApplicationInfo) ExtractFrom(readable types.Readable) error {
}

// Copy returns a new copied instance of ApplicationInfo
func (ai *ApplicationInfo) Copy() types.RVType {
func (ai ApplicationInfo) Copy() types.RVType {
copied := NewApplicationInfo()

copied.StructureVersion = ai.StructureVersion
copied.Data = ai.Data.Copy().(*types.Data)
copied.TitleID = ai.TitleID.Copy().(*types.PrimitiveU64)
copied.TitleVersion = ai.TitleVersion.Copy().(*types.PrimitiveU16)
copied.Data = ai.Data.Copy().(types.Data)
copied.TitleID = ai.TitleID.Copy().(types.UInt64)
copied.TitleVersion = ai.TitleVersion.Copy().(types.UInt16)

return copied
}

// Equals checks if the given ApplicationInfo contains the same data as the current ApplicationInfo
func (ai *ApplicationInfo) Equals(o types.RVType) bool {
if _, ok := o.(*ApplicationInfo); !ok {
func (ai ApplicationInfo) Equals(o types.RVType) bool {
if _, ok := o.(ApplicationInfo); !ok {
return false
}

other := o.(*ApplicationInfo)
other := o.(ApplicationInfo)

if ai.StructureVersion != other.StructureVersion {
return false
Expand All @@ -94,13 +94,27 @@ func (ai *ApplicationInfo) Equals(o types.RVType) bool {
return ai.TitleVersion.Equals(other.TitleVersion)
}

// CopyRef copies the current value of the ApplicationInfo
// and returns a pointer to the new copy
func (ai ApplicationInfo) CopyRef() types.RVTypePtr {
copied := ai.Copy().(ApplicationInfo)
return &copied
}

// Deref takes a pointer to the ApplicationInfo
// and dereferences it to the raw value.
// Only useful when working with an instance of RVTypePtr
func (ai *ApplicationInfo) Deref() types.RVType {
return *ai
}

// String returns the string representation of the ApplicationInfo
func (ai *ApplicationInfo) String() string {
func (ai ApplicationInfo) String() string {
return ai.FormatToString(0)
}

// FormatToString pretty-prints the ApplicationInfo using the provided indentation level
func (ai *ApplicationInfo) FormatToString(indentationLevel int) string {
func (ai ApplicationInfo) FormatToString(indentationLevel int) string {
indentationValues := strings.Repeat("\t", indentationLevel+1)
indentationEnd := strings.Repeat("\t", indentationLevel)

Expand All @@ -116,11 +130,11 @@ func (ai *ApplicationInfo) FormatToString(indentationLevel int) string {
}

// NewApplicationInfo returns a new ApplicationInfo
func NewApplicationInfo() *ApplicationInfo {
ai := &ApplicationInfo{
func NewApplicationInfo() ApplicationInfo {
ai := ApplicationInfo{
Data: types.NewData(),
TitleID: types.NewPrimitiveU64(0),
TitleVersion: types.NewPrimitiveU16(0),
TitleID: types.NewUInt64(0),
TitleVersion: types.NewUInt16(0),
}

return ai
Expand Down
4 changes: 2 additions & 2 deletions aa-user/unregister_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func (protocol *Protocol) handleUnregisterApplication(packet nex.PacketInterface
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

titleID := types.NewPrimitiveU64(0)
var titleID types.UInt64

err := titleID.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.UnregisterApplication(fmt.Errorf("Failed to read titleID from parameters. %s", err.Error()), packet, callID, nil)
_, rmcError := protocol.UnregisterApplication(fmt.Errorf("Failed to read titleID from parameters. %s", err.Error()), packet, callID, titleID)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
4 changes: 2 additions & 2 deletions account-management/change_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ func (protocol *Protocol) handleChangePassword(packet nex.PacketInterface) {
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

strNewKey := types.NewString("")
var strNewKey types.String

err := strNewKey.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.ChangePassword(fmt.Errorf("Failed to read strNewKey from parameters. %s", err.Error()), packet, callID, nil)
_, rmcError := protocol.ChangePassword(fmt.Errorf("Failed to read strNewKey from parameters. %s", err.Error()), packet, callID, strNewKey)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
12 changes: 6 additions & 6 deletions account-management/change_password_by_guest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func (protocol *Protocol) handleChangePasswordByGuest(packet nex.PacketInterface
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

strPrincipalName := types.NewString("")
strKey := types.NewString("")
strEmail := types.NewString("")
var strPrincipalName types.String
var strKey types.String
var strEmail types.String

var err error

err = strPrincipalName.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.ChangePasswordByGuest(fmt.Errorf("Failed to read strPrincipalName from parameters. %s", err.Error()), packet, callID, nil, nil, nil)
_, rmcError := protocol.ChangePasswordByGuest(fmt.Errorf("Failed to read strPrincipalName from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -43,7 +43,7 @@ func (protocol *Protocol) handleChangePasswordByGuest(packet nex.PacketInterface

err = strKey.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.ChangePasswordByGuest(fmt.Errorf("Failed to read strKey from parameters. %s", err.Error()), packet, callID, nil, nil, nil)
_, rmcError := protocol.ChangePasswordByGuest(fmt.Errorf("Failed to read strKey from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -53,7 +53,7 @@ func (protocol *Protocol) handleChangePasswordByGuest(packet nex.PacketInterface

err = strEmail.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.ChangePasswordByGuest(fmt.Errorf("Failed to read strEmail from parameters. %s", err.Error()), packet, callID, nil, nil, nil)
_, rmcError := protocol.ChangePasswordByGuest(fmt.Errorf("Failed to read strEmail from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
16 changes: 8 additions & 8 deletions account-management/create_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ func (protocol *Protocol) handleCreateAccount(packet nex.PacketInterface) {
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

strPrincipalName := types.NewString("")
strKey := types.NewString("")
uiGroups := types.NewPrimitiveU32(0)
strEmail := types.NewString("")
var strPrincipalName types.String
var strKey types.String
var uiGroups types.UInt32
var strEmail types.String

var err error

err = strPrincipalName.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read strPrincipalName from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read strPrincipalName from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -44,7 +44,7 @@ func (protocol *Protocol) handleCreateAccount(packet nex.PacketInterface) {

err = strKey.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read strKey from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read strKey from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -54,7 +54,7 @@ func (protocol *Protocol) handleCreateAccount(packet nex.PacketInterface) {

err = uiGroups.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read uiGroups from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read uiGroups from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -64,7 +64,7 @@ func (protocol *Protocol) handleCreateAccount(packet nex.PacketInterface) {

err = strEmail.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read strEmail from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccount(fmt.Errorf("Failed to read strEmail from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
24 changes: 12 additions & 12 deletions account-management/create_account_with_custom_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ func (protocol *Protocol) handleCreateAccountWithCustomData(packet nex.PacketInt
endpoint := packet.Sender().Endpoint()
parametersStream := nex.NewByteStreamIn(parameters, endpoint.LibraryVersions(), endpoint.ByteStreamSettings())

strPrincipalName := types.NewString("")
strKey := types.NewString("")
uiGroups := types.NewPrimitiveU32(0)
strEmail := types.NewString("")
oPublicData := types.NewAnyDataHolder()
oPrivateData := types.NewAnyDataHolder()
var strPrincipalName types.String
var strKey types.String
var uiGroups types.UInt32
var strEmail types.String
var oPublicData types.DataHolder
var oPrivateData types.DataHolder

var err error

err = strPrincipalName.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read strPrincipalName from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read strPrincipalName from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail, oPublicData, oPrivateData)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -46,7 +46,7 @@ func (protocol *Protocol) handleCreateAccountWithCustomData(packet nex.PacketInt

err = strKey.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read strKey from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read strKey from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail, oPublicData, oPrivateData)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -56,7 +56,7 @@ func (protocol *Protocol) handleCreateAccountWithCustomData(packet nex.PacketInt

err = uiGroups.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read uiGroups from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read uiGroups from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail, oPublicData, oPrivateData)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -66,7 +66,7 @@ func (protocol *Protocol) handleCreateAccountWithCustomData(packet nex.PacketInt

err = strEmail.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read strEmail from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read strEmail from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail, oPublicData, oPrivateData)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -76,7 +76,7 @@ func (protocol *Protocol) handleCreateAccountWithCustomData(packet nex.PacketInt

err = oPublicData.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read oPublicData from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read oPublicData from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail, oPublicData, oPrivateData)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand All @@ -86,7 +86,7 @@ func (protocol *Protocol) handleCreateAccountWithCustomData(packet nex.PacketInt

err = oPrivateData.ExtractFrom(parametersStream)
if err != nil {
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read oPrivateData from parameters. %s", err.Error()), packet, callID, nil, nil, nil, nil, nil, nil)
_, rmcError := protocol.CreateAccountWithCustomData(fmt.Errorf("Failed to read oPrivateData from parameters. %s", err.Error()), packet, callID, strPrincipalName, strKey, uiGroups, strEmail, oPublicData, oPrivateData)
if rmcError != nil {
globals.RespondError(packet, ProtocolID, rmcError)
}
Expand Down
Loading

0 comments on commit 0e0d9b6

Please sign in to comment.