IFriendService.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using Ryujinx.Common.Logging;
  2. using Ryujinx.HLE.HOS.Ipc;
  3. using Ryujinx.HLE.HOS.SystemState;
  4. using Ryujinx.HLE.Utilities;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.HLE.HOS.Services.Friend
  7. {
  8. class IFriendService : IpcService
  9. {
  10. private Dictionary<int, ServiceProcessRequest> _commands;
  11. public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
  12. public IFriendService()
  13. {
  14. _commands = new Dictionary<int, ServiceProcessRequest>
  15. {
  16. { 10101, GetFriendList },
  17. { 10600, DeclareOpenOnlinePlaySession },
  18. { 10601, DeclareCloseOnlinePlaySession },
  19. { 10610, UpdateUserPresence }
  20. };
  21. }
  22. // nn::friends::GetFriendListGetFriendListIds(nn::account::Uid, int Unknown0, nn::friends::detail::ipc::SizedFriendFilter, ulong Unknown1) -> int CounterIds, array<nn::account::NetworkServiceAccountId>
  23. public long GetFriendList(ServiceCtx context)
  24. {
  25. UInt128 uuid = new UInt128(
  26. context.RequestData.ReadInt64(),
  27. context.RequestData.ReadInt64());
  28. int unknown0 = context.RequestData.ReadInt32();
  29. FriendFilter filter = new FriendFilter
  30. {
  31. PresenceStatus = (PresenceStatusFilter)context.RequestData.ReadInt32(),
  32. IsFavoriteOnly = context.RequestData.ReadBoolean(),
  33. IsSameAppPresenceOnly = context.RequestData.ReadBoolean(),
  34. IsSameAppPlayedOnly = context.RequestData.ReadBoolean(),
  35. IsArbitraryAppPlayedOnly = context.RequestData.ReadBoolean(),
  36. PresenceGroupId = context.RequestData.ReadInt64()
  37. };
  38. long unknown1 = context.RequestData.ReadInt64();
  39. // There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
  40. context.ResponseData.Write(0);
  41. Logger.PrintStub(LogClass.ServiceFriend, new {
  42. UserId = uuid.ToString(),
  43. unknown0,
  44. filter.PresenceStatus,
  45. filter.IsFavoriteOnly,
  46. filter.IsSameAppPresenceOnly,
  47. filter.IsSameAppPlayedOnly,
  48. filter.IsArbitraryAppPlayedOnly,
  49. filter.PresenceGroupId,
  50. unknown1
  51. });
  52. return 0;
  53. }
  54. // DeclareOpenOnlinePlaySession(nn::account::Uid)
  55. public long DeclareOpenOnlinePlaySession(ServiceCtx context)
  56. {
  57. UInt128 uuid = new UInt128(
  58. context.RequestData.ReadInt64(),
  59. context.RequestData.ReadInt64());
  60. if (context.Device.System.State.TryGetUser(uuid, out UserProfile profile))
  61. {
  62. profile.OnlinePlayState = OpenCloseState.Open;
  63. }
  64. Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
  65. return 0;
  66. }
  67. // DeclareCloseOnlinePlaySession(nn::account::Uid)
  68. public long DeclareCloseOnlinePlaySession(ServiceCtx context)
  69. {
  70. UInt128 uuid = new UInt128(
  71. context.RequestData.ReadInt64(),
  72. context.RequestData.ReadInt64());
  73. if (context.Device.System.State.TryGetUser(uuid, out UserProfile profile))
  74. {
  75. profile.OnlinePlayState = OpenCloseState.Closed;
  76. }
  77. Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
  78. return 0;
  79. }
  80. // UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer<Unknown1, type: 0x19, size: 0xe0>
  81. public long UpdateUserPresence(ServiceCtx context)
  82. {
  83. UInt128 uuid = new UInt128(
  84. context.RequestData.ReadInt64(),
  85. context.RequestData.ReadInt64());
  86. long unknown0 = context.RequestData.ReadInt64();
  87. long position = context.Request.PtrBuff[0].Position;
  88. long size = context.Request.PtrBuff[0].Size;
  89. //Todo: Write the buffer content.
  90. Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), unknown0 });
  91. return 0;
  92. }
  93. }
  94. }