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
This commit is contained in:
parent
4926f6523d
commit
4ad3936afd
147 changed files with 1413 additions and 1477 deletions
|
@ -1,8 +0,0 @@
|
|||
namespace Ryujinx.HLE.HOS.Services.Friend
|
||||
{
|
||||
static class FriendError
|
||||
{
|
||||
public const int InvalidArgument = 2;
|
||||
public const int NotificationQueueEmpty = 15;
|
||||
}
|
||||
}
|
|
@ -16,4 +16,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend
|
|||
Manager = UserMask | OverlayMask | ManagerMask,
|
||||
System = UserMask | SystemMask
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -101,4 +101,4 @@ namespace Ryujinx.HLE.HOS.Services.Friend
|
|||
|
||||
public long NetworkUserIdPlaceholder;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
13
Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs
Normal file
13
Ryujinx.HLE/HOS/Services/Friend/ResultCode.cs
Normal file
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue