IServiceCreator.cs 1.8 KB

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