IOlscServiceForApplication.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using Ryujinx.Common;
  2. using Ryujinx.Common.Logging;
  3. using Ryujinx.HLE.HOS.Services.Account.Acc;
  4. using System.Collections.Generic;
  5. namespace Ryujinx.HLE.HOS.Services.Olsc
  6. {
  7. [Service("olsc:u")] // 10.0.0+
  8. class IOlscServiceForApplication : IpcService
  9. {
  10. private bool _initialized;
  11. private Dictionary<UserId, bool> _saveDataBackupSettingDatabase;
  12. public IOlscServiceForApplication(ServiceCtx context) { }
  13. [CommandHipc(0)]
  14. // Initialize(pid)
  15. public ResultCode Initialize(ServiceCtx context)
  16. {
  17. // NOTE: Service call arp:r GetApplicationInstanceUnregistrationNotifier with the pid and initialize some internal struct.
  18. // Since we will not support online savedata backup, it's fine to stub it for now.
  19. _saveDataBackupSettingDatabase = new Dictionary<UserId, bool>();
  20. _initialized = true;
  21. Logger.Stub?.PrintStub(LogClass.ServiceOlsc);
  22. return ResultCode.Success;
  23. }
  24. [CommandHipc(13)]
  25. // GetSaveDataBackupSetting(nn::account::Uid) -> u8
  26. public ResultCode GetSaveDataBackupSetting(ServiceCtx context)
  27. {
  28. UserId userId = context.RequestData.ReadStruct<UserId>();
  29. if (!_initialized)
  30. {
  31. return ResultCode.NotInitialized;
  32. }
  33. if (userId.IsNull)
  34. {
  35. return ResultCode.NullArgument;
  36. }
  37. if (_saveDataBackupSettingDatabase.TryGetValue(userId, out bool enabled) && enabled)
  38. {
  39. context.ResponseData.Write((byte)1); // TODO: Determine value.
  40. }
  41. else
  42. {
  43. context.ResponseData.Write((byte)2); // TODO: Determine value.
  44. }
  45. // NOTE: Since we will not support online savedata backup, it's fine to stub it for now.
  46. Logger.Stub?.PrintStub(LogClass.ServiceOlsc, new { userId });
  47. return ResultCode.Success;
  48. }
  49. [CommandHipc(14)]
  50. // SetSaveDataBackupSettingEnabled(nn::account::Uid, bool)
  51. public ResultCode SetSaveDataBackupSettingEnabled(ServiceCtx context)
  52. {
  53. bool saveDataBackupSettingEnabled = context.RequestData.ReadUInt64() != 0;
  54. UserId userId = context.RequestData.ReadStruct<UserId>();
  55. if (!_initialized)
  56. {
  57. return ResultCode.NotInitialized;
  58. }
  59. if (userId.IsNull)
  60. {
  61. return ResultCode.NullArgument;
  62. }
  63. _saveDataBackupSettingDatabase[userId] = saveDataBackupSettingEnabled;
  64. // NOTE: Since we will not support online savedata backup, it's fine to stub it for now.
  65. Logger.Stub?.PrintStub(LogClass.ServiceOlsc, new { userId, saveDataBackupSettingEnabled });
  66. return ResultCode.Success;
  67. }
  68. }
  69. }