IFriendService.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. { 10601, DeclareCloseOnlinePlaySession },
  18. { 10610, UpdateUserPresence }
  19. };
  20. }
  21. // nn::friends::GetFriendListGetFriendListIds(nn::account::Uid, int Unknown0, nn::friends::detail::ipc::SizedFriendFilter, ulong Unknown1) -> int CounterIds, array<nn::account::NetworkServiceAccountId>
  22. public long GetFriendList(ServiceCtx context)
  23. {
  24. UInt128 uuid = new UInt128(
  25. context.RequestData.ReadInt64(),
  26. context.RequestData.ReadInt64());
  27. int unknown0 = context.RequestData.ReadInt32();
  28. FriendFilter filter = new FriendFilter
  29. {
  30. PresenceStatus = (PresenceStatusFilter)context.RequestData.ReadInt32(),
  31. IsFavoriteOnly = context.RequestData.ReadBoolean(),
  32. IsSameAppPresenceOnly = context.RequestData.ReadBoolean(),
  33. IsSameAppPlayedOnly = context.RequestData.ReadBoolean(),
  34. IsArbitraryAppPlayedOnly = context.RequestData.ReadBoolean(),
  35. PresenceGroupId = context.RequestData.ReadInt64()
  36. };
  37. long unknown1 = context.RequestData.ReadInt64();
  38. // There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
  39. context.ResponseData.Write(0);
  40. Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. UserId: {uuid.ToString()} - " +
  41. $"Unknown0: {unknown0} - " +
  42. $"PresenceStatus: {filter.PresenceStatus} - " +
  43. $"IsFavoriteOnly: {filter.IsFavoriteOnly} - " +
  44. $"IsSameAppPresenceOnly: {filter.IsSameAppPresenceOnly} - " +
  45. $"IsSameAppPlayedOnly: {filter.IsSameAppPlayedOnly} - " +
  46. $"IsArbitraryAppPlayedOnly: {filter.IsArbitraryAppPlayedOnly} - " +
  47. $"PresenceGroupId: {filter.PresenceGroupId} - " +
  48. $"Unknown1: {unknown1}");
  49. return 0;
  50. }
  51. // DeclareCloseOnlinePlaySession(nn::account::Uid)
  52. public long DeclareCloseOnlinePlaySession(ServiceCtx context)
  53. {
  54. UInt128 uuid = new UInt128(
  55. context.RequestData.ReadInt64(),
  56. context.RequestData.ReadInt64());
  57. if (context.Device.System.State.TryGetUser(uuid, out UserProfile profile))
  58. {
  59. profile.OnlinePlayState = OpenCloseState.Closed;
  60. }
  61. Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {uuid.ToString()} - " +
  62. $"OnlinePlayState: {profile.OnlinePlayState}");
  63. return 0;
  64. }
  65. // UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer<Unknown1, type: 0x19, size: 0xe0>
  66. public long UpdateUserPresence(ServiceCtx context)
  67. {
  68. UInt128 uuid = new UInt128(
  69. context.RequestData.ReadInt64(),
  70. context.RequestData.ReadInt64());
  71. long unknown0 = context.RequestData.ReadInt64();
  72. long position = context.Request.PtrBuff[0].Position;
  73. long size = context.Request.PtrBuff[0].Size;
  74. //Todo: Write the buffer content.
  75. Logger.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {uuid.ToString()} - " +
  76. $"Unknown0: {unknown0}");
  77. return 0;
  78. }
  79. }
  80. }