IFriendService.cs 4.4 KB

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