diff options
| author | Ac_K <Acoustik666@gmail.com> | 2019-07-14 21:04:38 +0200 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2019-07-14 16:04:38 -0300 |
| commit | 4ad3936afd4ca393a05b330e3848958e9598e910 (patch) | |
| tree | e0b3bc963230d3ea3d6cc57b5bc6caeba9233479 /Ryujinx.HLE/HOS/Services/Friend | |
| parent | 4926f6523d3130879e108403979ab68f1212f544 (diff) | |
Refactoring result codes (#731)
* refactoring result codes
- Add a main enum who can handle some orphalin result codes and the default `ResultCode.Success` one.
- Add sub-enum by services when it's needed.
- Remove some empty line.
- Recast all service calls to ResultCode.
- Remove some unneeded static declaration.
- Delete unused `NvHelper` class.
* NvResult is back
* Fix
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Friend')
7 files changed, 44 insertions, 45 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Friend/FriendError.cs b/Ryujinx.HLE/HOS/Services/Friend/FriendError.cs deleted file mode 100644 index 49bc4c67..00000000 --- a/Ryujinx.HLE/HOS/Services/Friend/FriendError.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Ryujinx.HLE.HOS.Services.Friend -{ - static class FriendError - { - public const int InvalidArgument = 2; - public const int NotificationQueueEmpty = 15; - } -} diff --git a/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs b/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs index 2ddb0b85..a2a4031a 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/FriendServicePermissionLevel.cs @@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend Manager = UserMask | OverlayMask | ManagerMask, System = UserMask | SystemMask } -} +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs b/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs index 40a54ee2..ed3bc284 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/IFriendService.cs @@ -5,8 +5,6 @@ using Ryujinx.HLE.Utilities; using System.IO; using System.Runtime.InteropServices; -using static Ryujinx.HLE.HOS.ErrorCode; - namespace Ryujinx.HLE.HOS.Services.Friend { class IFriendService : IpcService @@ -21,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend [Command(10100)] // nn::friends::GetFriendListIds(int offset, nn::account::Uid userUUID, nn::friends::detail::ipc::SizedFriendFilter friendFilter, ulong pidPlaceHolder, pid) // -> int outCount, array<nn::account::NetworkServiceAccountId, 0xa> - public long GetFriendListIds(ServiceCtx context) + public ResultCode GetFriendListIds(ServiceCtx context) { int offset = context.RequestData.ReadInt32(); @@ -36,7 +34,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend if (uuid.IsNull) { - return MakeError(ErrorModule.Friends, FriendError.InvalidArgument); + return ResultCode.InvalidArgument; } // There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty. @@ -54,13 +52,13 @@ namespace Ryujinx.HLE.HOS.Services.Friend filter.PresenceGroupId, }); - return 0; + return ResultCode.Success; } [Command(10101)] // nn::friends::GetFriendList(int offset, nn::account::Uid userUUID, nn::friends::detail::ipc::SizedFriendFilter friendFilter, ulong pidPlaceHolder, pid) // -> int outCount, array<nn::friends::detail::FriendImpl, 0x6> - public long GetFriendList(ServiceCtx context) + public ResultCode GetFriendList(ServiceCtx context) { int offset = context.RequestData.ReadInt32(); @@ -75,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend if (uuid.IsNull) { - return MakeError(ErrorModule.Friends, FriendError.InvalidArgument); + return ResultCode.InvalidArgument; } // There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty. @@ -92,18 +90,18 @@ namespace Ryujinx.HLE.HOS.Services.Friend filter.PresenceGroupId, }); - return 0; + return ResultCode.Success; } [Command(10600)] // nn::friends::DeclareOpenOnlinePlaySession(nn::account::Uid) - public long DeclareOpenOnlinePlaySession(ServiceCtx context) + public ResultCode DeclareOpenOnlinePlaySession(ServiceCtx context) { UInt128 uuid = context.RequestData.ReadStruct<UInt128>(); if (uuid.IsNull) { - return MakeError(ErrorModule.Friends, FriendError.InvalidArgument); + return ResultCode.InvalidArgument; } if (context.Device.System.State.Account.TryGetUser(uuid, out UserProfile profile)) @@ -113,18 +111,18 @@ namespace Ryujinx.HLE.HOS.Services.Friend Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState }); - return 0; + return ResultCode.Success; } [Command(10601)] // nn::friends::DeclareCloseOnlinePlaySession(nn::account::Uid) - public long DeclareCloseOnlinePlaySession(ServiceCtx context) + public ResultCode DeclareCloseOnlinePlaySession(ServiceCtx context) { UInt128 uuid = context.RequestData.ReadStruct<UInt128>(); if (uuid.IsNull) { - return MakeError(ErrorModule.Friends, FriendError.InvalidArgument); + return ResultCode.InvalidArgument; } if (context.Device.System.State.Account.TryGetUser(uuid, out UserProfile profile)) @@ -134,12 +132,12 @@ namespace Ryujinx.HLE.HOS.Services.Friend Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState }); - return 0; + return ResultCode.Success; } [Command(10610)] // nn::friends::UpdateUserPresence(nn::account::Uid, u64, pid, buffer<nn::friends::detail::UserPresenceImpl, 0x19>) - public long UpdateUserPresence(ServiceCtx context) + public ResultCode UpdateUserPresence(ServiceCtx context) { UInt128 uuid = context.RequestData.ReadStruct<UInt128>(); @@ -153,7 +151,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend if (uuid.IsNull) { - return MakeError(ErrorModule.Friends, FriendError.InvalidArgument); + return ResultCode.InvalidArgument; } int elementCount = bufferContent.Length / Marshal.SizeOf<UserPresence>(); @@ -165,7 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), userPresenceInputArray }); } - return 0; + return ResultCode.Success; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs b/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs index 7eb1b43b..5a5238f5 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/IFriendServiceTypes.cs @@ -101,4 +101,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend public long NetworkUserIdPlaceholder; } -} +}
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs b/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs index 87abc839..7cff84bd 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/INotificationService.cs @@ -6,8 +6,6 @@ using Ryujinx.HLE.Utilities; using System; using System.Collections.Generic; -using static Ryujinx.HLE.HOS.ErrorCode; - namespace Ryujinx.HLE.HOS.Services.Friend { class INotificationService : IpcService, IDisposable @@ -40,7 +38,7 @@ namespace Ryujinx.HLE.HOS.Services.Friend [Command(0)] //2.0.0+ // nn::friends::detail::ipc::INotificationService::GetEvent() -> handle<copy> - public long GetEvent(ServiceCtx context) + public ResultCode GetEvent(ServiceCtx context) { if (_notificationEventHandle == 0) { @@ -52,12 +50,12 @@ namespace Ryujinx.HLE.HOS.Services.Friend context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_notificationEventHandle); - return 0; + return ResultCode.Success; } [Command(1)] //2.0.0+ // nn::friends::detail::ipc::INotificationService::Clear() - public long Clear(ServiceCtx context) + public ResultCode Clear(ServiceCtx context) { lock (_lock) { @@ -67,12 +65,12 @@ namespace Ryujinx.HLE.HOS.Services.Friend _notifications.Clear(); } - return 0; + return ResultCode.Success; } [Command(2)] // 2.0.0+ // nn::friends::detail::ipc::INotificationService::Pop() -> nn::friends::detail::ipc::SizedNotificationInfo - public long Pop(ServiceCtx context) + public ResultCode Pop(ServiceCtx context) { lock (_lock) { @@ -92,11 +90,11 @@ namespace Ryujinx.HLE.HOS.Services.Friend context.ResponseData.WriteStruct(notificationInfo); - return 0; + return ResultCode.Success; } } - return MakeError(ErrorModule.Friends, FriendError.NotificationQueueEmpty); + return ResultCode.NotificationQueueEmpty; } public void SignalFriendListUpdate(UInt128 targetId) diff --git a/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs b/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs index 2f798769..c907a2ed 100644 --- a/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs +++ b/Ryujinx.HLE/HOS/Services/Friend/IServiceCreator.cs @@ -1,8 +1,6 @@ using Ryujinx.Common; using Ryujinx.HLE.Utilities; -using static Ryujinx.HLE.HOS.ErrorCode; - namespace Ryujinx.HLE.HOS.Services.Friend { [Service("friend:a", FriendServicePermissionLevel.Admin)] @@ -21,36 +19,36 @@ namespace Ryujinx.HLE.HOS.Services.Friend [Command(0)] // CreateFriendService() -> object<nn::friends::detail::ipc::IFriendService> - public long CreateFriendService(ServiceCtx context) + public ResultCode CreateFriendService(ServiceCtx context) { MakeObject(context, new IFriendService(_permissionLevel)); - return 0; + return ResultCode.Success; } [Command(1)] // 2.0.0+ // CreateNotificationService(nn::account::Uid) -> object<nn::friends::detail::ipc::INotificationService> - public long CreateNotificationService(ServiceCtx context) + public ResultCode CreateNotificationService(ServiceCtx context) { UInt128 userId = context.RequestData.ReadStruct<UInt128>(); if (userId.IsNull) { - return MakeError(ErrorModule.Friends, FriendError.InvalidArgument); + return ResultCode.InvalidArgument; } MakeObject(context, new INotificationService(context, userId, _permissionLevel)); - return 0; + return ResultCode.Success; } [Command(2)] // 4.0.0+ // CreateDaemonSuspendSessionService() -> object<nn::friends::detail::ipc::IDaemonSuspendSessionService> - public long CreateDaemonSuspendSessionService(ServiceCtx context) + public ResultCode CreateDaemonSuspendSessionService(ServiceCtx context) { MakeObject(context, new IDaemonSuspendSessionService(_permissionLevel)); - return 0; + return ResultCode.Success; } } }
\ No newline at end of file diff --git a/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs b/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs new file mode 100644 index 00000000..2edc20cb --- /dev/null +++ b/Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs @@ -0,0 +1,13 @@ +namespace Ryujinx.HLE.HOS.Services.Friend +{ + enum ResultCode + { + ModuleId = 121, + ErrorCodeShift = 9, + + Success = 0, + + InvalidArgument = (2 << ErrorCodeShift) | ModuleId, + NotificationQueueEmpty = (15 << ErrorCodeShift) | ModuleId + } +}
\ No newline at end of file |
