2018-10-17 13:15:50 -04:00
|
|
|
using Ryujinx.Common.Logging;
|
2018-08-16 19:47:36 -04:00
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
using Ryujinx.HLE.HOS.SystemState;
|
2018-10-07 09:13:46 -04:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-02-09 19:14:55 -05:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-08-16 19:47:36 -04:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Friend
|
2018-02-09 19:14:55 -05:00
|
|
|
{
|
2018-03-19 14:58:46 -04:00
|
|
|
class IFriendService : IpcService
|
2018-02-09 19:14:55 -05:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
private Dictionary<int, ServiceProcessRequest> _commands;
|
2018-02-09 19:14:55 -05:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
2018-02-09 19:14:55 -05:00
|
|
|
|
|
|
|
public IFriendService()
|
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
2018-02-09 19:14:55 -05:00
|
|
|
{
|
2018-09-25 18:59:29 -04:00
|
|
|
{ 10101, GetFriendList },
|
2019-04-25 09:03:00 -04:00
|
|
|
{ 10600, DeclareOpenOnlinePlaySession },
|
2018-08-14 18:02:42 -04:00
|
|
|
{ 10601, DeclareCloseOnlinePlaySession },
|
|
|
|
{ 10610, UpdateUserPresence }
|
2018-02-09 19:14:55 -05:00
|
|
|
};
|
|
|
|
}
|
2018-08-14 18:02:42 -04:00
|
|
|
|
2018-09-25 18:59:29 -04:00
|
|
|
// nn::friends::GetFriendListGetFriendListIds(nn::account::Uid, int Unknown0, nn::friends::detail::ipc::SizedFriendFilter, ulong Unknown1) -> int CounterIds, array<nn::account::NetworkServiceAccountId>
|
2018-12-06 06:16:24 -05:00
|
|
|
public long GetFriendList(ServiceCtx context)
|
2018-09-25 18:59:29 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
UInt128 uuid = new UInt128(
|
|
|
|
context.RequestData.ReadInt64(),
|
|
|
|
context.RequestData.ReadInt64());
|
2018-09-25 18:59:29 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
int unknown0 = context.RequestData.ReadInt32();
|
2018-09-25 18:59:29 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
FriendFilter filter = new FriendFilter
|
2018-09-25 18:59:29 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
PresenceStatus = (PresenceStatusFilter)context.RequestData.ReadInt32(),
|
|
|
|
IsFavoriteOnly = context.RequestData.ReadBoolean(),
|
|
|
|
IsSameAppPresenceOnly = context.RequestData.ReadBoolean(),
|
|
|
|
IsSameAppPlayedOnly = context.RequestData.ReadBoolean(),
|
|
|
|
IsArbitraryAppPlayedOnly = context.RequestData.ReadBoolean(),
|
|
|
|
PresenceGroupId = context.RequestData.ReadInt64()
|
2018-09-25 18:59:29 -04:00
|
|
|
};
|
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
long unknown1 = context.RequestData.ReadInt64();
|
2018-09-25 18:59:29 -04:00
|
|
|
|
|
|
|
// There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
|
2018-12-06 06:16:24 -05:00
|
|
|
context.ResponseData.Write(0);
|
|
|
|
|
2019-01-10 19:11:46 -05:00
|
|
|
Logger.PrintStub(LogClass.ServiceFriend, new {
|
|
|
|
UserId = uuid.ToString(),
|
|
|
|
unknown0,
|
|
|
|
filter.PresenceStatus,
|
|
|
|
filter.IsFavoriteOnly,
|
|
|
|
filter.IsSameAppPresenceOnly,
|
|
|
|
filter.IsSameAppPlayedOnly,
|
|
|
|
filter.IsArbitraryAppPlayedOnly,
|
|
|
|
filter.PresenceGroupId,
|
|
|
|
unknown1
|
|
|
|
});
|
2018-09-25 18:59:29 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-25 09:03:00 -04:00
|
|
|
// DeclareOpenOnlinePlaySession(nn::account::Uid)
|
|
|
|
public long DeclareOpenOnlinePlaySession(ServiceCtx context)
|
|
|
|
{
|
|
|
|
UInt128 uuid = new UInt128(
|
|
|
|
context.RequestData.ReadInt64(),
|
|
|
|
context.RequestData.ReadInt64());
|
|
|
|
|
2019-06-15 18:35:38 -04:00
|
|
|
if (context.Device.System.State.Account.TryGetUser(uuid, out UserProfile profile))
|
2019-04-25 09:03:00 -04:00
|
|
|
{
|
2019-06-15 18:35:38 -04:00
|
|
|
profile.OnlinePlayState = AccountState.Open;
|
2019-04-25 09:03:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-25 18:59:29 -04:00
|
|
|
// DeclareCloseOnlinePlaySession(nn::account::Uid)
|
2018-12-06 06:16:24 -05:00
|
|
|
public long DeclareCloseOnlinePlaySession(ServiceCtx context)
|
2018-08-14 18:02:42 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
UInt128 uuid = new UInt128(
|
|
|
|
context.RequestData.ReadInt64(),
|
|
|
|
context.RequestData.ReadInt64());
|
2018-08-14 18:02:42 -04:00
|
|
|
|
2019-06-15 18:35:38 -04:00
|
|
|
if (context.Device.System.State.Account.TryGetUser(uuid, out UserProfile profile))
|
2018-08-14 18:02:42 -04:00
|
|
|
{
|
2019-06-15 18:35:38 -04:00
|
|
|
profile.OnlinePlayState = AccountState.Closed;
|
2018-08-14 18:02:42 -04:00
|
|
|
}
|
|
|
|
|
2019-01-10 19:11:46 -05:00
|
|
|
Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), profile.OnlinePlayState });
|
2018-09-25 18:59:29 -04:00
|
|
|
|
2018-08-14 18:02:42 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-25 18:59:29 -04:00
|
|
|
// UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer<Unknown1, type: 0x19, size: 0xe0>
|
2018-12-06 06:16:24 -05:00
|
|
|
public long UpdateUserPresence(ServiceCtx context)
|
2018-08-14 18:02:42 -04:00
|
|
|
{
|
2018-12-06 06:16:24 -05:00
|
|
|
UInt128 uuid = new UInt128(
|
|
|
|
context.RequestData.ReadInt64(),
|
|
|
|
context.RequestData.ReadInt64());
|
2018-08-14 18:02:42 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
long unknown0 = context.RequestData.ReadInt64();
|
2018-09-25 18:59:29 -04:00
|
|
|
|
2018-12-06 06:16:24 -05:00
|
|
|
long position = context.Request.PtrBuff[0].Position;
|
|
|
|
long size = context.Request.PtrBuff[0].Size;
|
2018-09-25 18:59:29 -04:00
|
|
|
|
2019-07-01 22:39:22 -04:00
|
|
|
// TODO: Write the buffer content.
|
2018-09-25 18:59:29 -04:00
|
|
|
|
2019-01-10 19:11:46 -05:00
|
|
|
Logger.PrintStub(LogClass.ServiceFriend, new { UserId = uuid.ToString(), unknown0 });
|
2018-08-14 18:02:42 -04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-09 19:14:55 -05:00
|
|
|
}
|
2018-09-25 18:59:29 -04:00
|
|
|
}
|