IFriendService.cs 3.7 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, new {
  41. UserId = uuid.ToString(),
  42. unknown0,
  43. filter.PresenceStatus,
  44. filter.IsFavoriteOnly,
  45. filter.IsSameAppPresenceOnly,
  46. filter.IsSameAppPlayedOnly,
  47. filter.IsArbitraryAppPlayedOnly,
  48. filter.PresenceGroupId,
  49. unknown1
  50. });
  51. return 0;
  52. }
  53. // DeclareCloseOnlinePlaySession(nn::account::Uid)
  54. public long DeclareCloseOnlinePlaySession(ServiceCtx context)
  55. {
  56. UInt128 uuid = new UInt128(
  57. context.RequestData.ReadInt64(),
  58. context.RequestData.ReadInt64());
  59. if (context.Device.System.State.TryGetUser(uuid, out UserProfile profile))
  60. {
  61. profile.OnlinePlayState = OpenCloseState.Closed;
  62. }
  63. Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
  64. return 0;
  65. }
  66. // UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer<Unknown1, type: 0x19, size: 0xe0>
  67. public long UpdateUserPresence(ServiceCtx context)
  68. {
  69. UInt128 uuid = new UInt128(
  70. context.RequestData.ReadInt64(),
  71. context.RequestData.ReadInt64());
  72. long unknown0 = context.RequestData.ReadInt64();
  73. long position = context.Request.PtrBuff[0].Position;
  74. long size = context.Request.PtrBuff[0].Size;
  75. //Todo: Write the buffer content.
  76. Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), unknown0 });
  77. return 0;
  78. }
  79. }
  80. }