IAccountServiceForAdministrator.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.HLE.HOS.Services.Account.Acc.AccountService;
  4. namespace Ryujinx.HLE.HOS.Services.Account.Acc
  5. {
  6. [Service("acc:su", AccountServiceFlag.Administrator)] // Max Sessions: 8
  7. class IAccountServiceForAdministrator : IpcService
  8. {
  9. private ApplicationServiceServer _applicationServiceServer;
  10. public IAccountServiceForAdministrator(ServiceCtx context, AccountServiceFlag serviceFlag)
  11. {
  12. _applicationServiceServer = new ApplicationServiceServer(serviceFlag);
  13. }
  14. [CommandHipc(0)]
  15. // GetUserCount() -> i32
  16. public ResultCode GetUserCount(ServiceCtx context)
  17. {
  18. return _applicationServiceServer.GetUserCountImpl(context);
  19. }
  20. [CommandHipc(1)]
  21. // GetUserExistence(nn::account::Uid) -> bool
  22. public ResultCode GetUserExistence(ServiceCtx context)
  23. {
  24. return _applicationServiceServer.GetUserExistenceImpl(context);
  25. }
  26. [CommandHipc(2)]
  27. // ListAllUsers() -> array<nn::account::Uid, 0xa>
  28. public ResultCode ListAllUsers(ServiceCtx context)
  29. {
  30. return _applicationServiceServer.ListAllUsers(context);
  31. }
  32. [CommandHipc(3)]
  33. // ListOpenUsers() -> array<nn::account::Uid, 0xa>
  34. public ResultCode ListOpenUsers(ServiceCtx context)
  35. {
  36. return _applicationServiceServer.ListOpenUsers(context);
  37. }
  38. [CommandHipc(4)]
  39. // GetLastOpenedUser() -> nn::account::Uid
  40. public ResultCode GetLastOpenedUser(ServiceCtx context)
  41. {
  42. return _applicationServiceServer.GetLastOpenedUser(context);
  43. }
  44. [CommandHipc(5)]
  45. // GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
  46. public ResultCode GetProfile(ServiceCtx context)
  47. {
  48. ResultCode resultCode = _applicationServiceServer.GetProfile(context, out IProfile iProfile);
  49. if (resultCode == ResultCode.Success)
  50. {
  51. MakeObject(context, iProfile);
  52. }
  53. return resultCode;
  54. }
  55. [CommandHipc(50)]
  56. // IsUserRegistrationRequestPermitted(pid) -> bool
  57. public ResultCode IsUserRegistrationRequestPermitted(ServiceCtx context)
  58. {
  59. // NOTE: pid is unused.
  60. return _applicationServiceServer.IsUserRegistrationRequestPermitted(context);
  61. }
  62. [CommandHipc(51)]
  63. // TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
  64. public ResultCode TrySelectUserWithoutInteraction(ServiceCtx context)
  65. {
  66. return _applicationServiceServer.TrySelectUserWithoutInteraction(context);
  67. }
  68. [CommandHipc(102)]
  69. // GetBaasAccountManagerForSystemService(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
  70. public ResultCode GetBaasAccountManagerForSystemService(ServiceCtx context)
  71. {
  72. ResultCode resultCode = _applicationServiceServer.CheckUserId(context, out UserId userId);
  73. if (resultCode != ResultCode.Success)
  74. {
  75. return resultCode;
  76. }
  77. MakeObject(context, new IManagerForSystemService(userId));
  78. // Doesn't occur in our case.
  79. // return ResultCode.NullObject;
  80. return ResultCode.Success;
  81. }
  82. [CommandHipc(140)] // 6.0.0+
  83. // ListQualifiedUsers() -> array<nn::account::Uid, 0xa>
  84. public ResultCode ListQualifiedUsers(ServiceCtx context)
  85. {
  86. return _applicationServiceServer.ListQualifiedUsers(context);
  87. }
  88. [CommandHipc(205)]
  89. // GetProfileEditor(nn::account::Uid) -> object<nn::account::profile::IProfileEditor>
  90. public ResultCode GetProfileEditor(ServiceCtx context)
  91. {
  92. UserId userId = context.RequestData.ReadStruct<UserId>();
  93. if (!context.Device.System.AccountManager.TryGetUser(userId, out UserProfile userProfile))
  94. {
  95. Logger.Warning?.Print(LogClass.ServiceAcc, $"User 0x{userId} not found!");
  96. return ResultCode.UserNotFound;
  97. }
  98. MakeObject(context, new IProfileEditor(userProfile));
  99. // Doesn't occur in our case.
  100. // return ResultCode.NullObject;
  101. return ResultCode.Success;
  102. }
  103. }
  104. }