IServiceCreator.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Ryujinx.Common;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.Utilities;
  4. using System.Collections.Generic;
  5. using static Ryujinx.HLE.HOS.ErrorCode;
  6. namespace Ryujinx.HLE.HOS.Services.Friend
  7. {
  8. class IServiceCreator : IpcService
  9. {
  10. private Dictionary<int, ServiceProcessRequest> _commands;
  11. private FriendServicePermissionLevel _permissionLevel;
  12. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  13. public IServiceCreator(FriendServicePermissionLevel permissionLevel)
  14. {
  15. _commands = new Dictionary<int, ServiceProcessRequest>
  16. {
  17. { 0, CreateFriendService },
  18. { 1, CreateNotificationService }, // 2.0.0+
  19. { 2, CreateDaemonSuspendSessionService }, // 4.0.0+
  20. };
  21. _permissionLevel = permissionLevel;
  22. }
  23. // CreateFriendService() -> object<nn::friends::detail::ipc::IFriendService>
  24. public long CreateFriendService(ServiceCtx context)
  25. {
  26. MakeObject(context, new IFriendService(_permissionLevel));
  27. return 0;
  28. }
  29. // CreateNotificationService(nn::account::Uid) -> object<nn::friends::detail::ipc::INotificationService>
  30. public long CreateNotificationService(ServiceCtx context)
  31. {
  32. UInt128 userId = context.RequestData.ReadStruct<UInt128>();
  33. if (userId.IsNull)
  34. {
  35. return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
  36. }
  37. MakeObject(context, new INotificationService(context, userId, _permissionLevel));
  38. return 0;
  39. }
  40. // CreateDaemonSuspendSessionService() -> object<nn::friends::detail::ipc::IDaemonSuspendSessionService>
  41. public long CreateDaemonSuspendSessionService(ServiceCtx context)
  42. {
  43. MakeObject(context, new IDaemonSuspendSessionService(_permissionLevel));
  44. return 0;
  45. }
  46. }
  47. }