2018-08-17 01:47:36 +02:00
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
using Ryujinx.HLE.HOS.SystemState;
|
2018-08-15 00:02:42 +02:00
|
|
|
using Ryujinx.HLE.Logging;
|
2018-10-07 15:13:46 +02:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-02-10 01:14:55 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Friend
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
2018-03-19 19:58:46 +01:00
|
|
|
class IFriendService : IpcService
|
2018-02-10 01:14:55 +01:00
|
|
|
{
|
|
|
|
private Dictionary<int, ServiceProcessRequest> m_Commands;
|
|
|
|
|
2018-03-19 19:58:46 +01:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
2018-02-10 01:14:55 +01:00
|
|
|
|
|
|
|
public IFriendService()
|
|
|
|
{
|
|
|
|
m_Commands = new Dictionary<int, ServiceProcessRequest>()
|
|
|
|
{
|
2018-09-26 00:59:29 +02:00
|
|
|
{ 10101, GetFriendList },
|
2018-08-15 00:02:42 +02:00
|
|
|
{ 10601, DeclareCloseOnlinePlaySession },
|
|
|
|
{ 10610, UpdateUserPresence }
|
2018-02-10 01:14:55 +01:00
|
|
|
};
|
|
|
|
}
|
2018-08-15 00:02:42 +02:00
|
|
|
|
2018-09-26 00:59:29 +02:00
|
|
|
// nn::friends::GetFriendListGetFriendListIds(nn::account::Uid, int Unknown0, nn::friends::detail::ipc::SizedFriendFilter, ulong Unknown1) -> int CounterIds, array<nn::account::NetworkServiceAccountId>
|
|
|
|
public long GetFriendList(ServiceCtx Context)
|
|
|
|
{
|
2018-10-07 15:13:46 +02:00
|
|
|
UInt128 Uuid = new UInt128(
|
2018-09-26 00:59:29 +02:00
|
|
|
Context.RequestData.ReadInt64(),
|
|
|
|
Context.RequestData.ReadInt64());
|
|
|
|
|
|
|
|
int Unknown0 = Context.RequestData.ReadInt32();
|
|
|
|
|
|
|
|
FriendFilter Filter = new FriendFilter()
|
|
|
|
{
|
|
|
|
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()
|
|
|
|
};
|
|
|
|
|
|
|
|
long Unknown1 = Context.RequestData.ReadInt64();
|
|
|
|
|
|
|
|
// There are no friends online, so we return 0 because the nn::account::NetworkServiceAccountId array is empty.
|
|
|
|
Context.ResponseData.Write(0);
|
|
|
|
|
2018-10-07 15:13:46 +02:00
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceFriend, $"Stubbed. UserId: {Uuid.ToString()} - " +
|
2018-09-26 00:59:29 +02:00
|
|
|
$"Unknown0: {Unknown0} - " +
|
|
|
|
$"PresenceStatus: {Filter.PresenceStatus} - " +
|
|
|
|
$"IsFavoriteOnly: {Filter.IsFavoriteOnly} - " +
|
|
|
|
$"IsSameAppPresenceOnly: {Filter.IsSameAppPresenceOnly} - " +
|
|
|
|
$"IsSameAppPlayedOnly: {Filter.IsSameAppPlayedOnly} - " +
|
|
|
|
$"IsArbitraryAppPlayedOnly: {Filter.IsArbitraryAppPlayedOnly} - " +
|
|
|
|
$"PresenceGroupId: {Filter.PresenceGroupId} - " +
|
|
|
|
$"Unknown1: {Unknown1}");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// DeclareCloseOnlinePlaySession(nn::account::Uid)
|
2018-08-15 00:02:42 +02:00
|
|
|
public long DeclareCloseOnlinePlaySession(ServiceCtx Context)
|
|
|
|
{
|
2018-10-07 15:13:46 +02:00
|
|
|
UInt128 Uuid = new UInt128(
|
2018-08-15 00:02:42 +02:00
|
|
|
Context.RequestData.ReadInt64(),
|
|
|
|
Context.RequestData.ReadInt64());
|
|
|
|
|
2018-08-17 01:47:36 +02:00
|
|
|
if (Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile))
|
2018-08-15 00:02:42 +02:00
|
|
|
{
|
|
|
|
Profile.OnlinePlayState = OpenCloseState.Closed;
|
|
|
|
}
|
|
|
|
|
2018-10-07 15:13:46 +02:00
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {Uuid.ToString()} - " +
|
2018-09-26 00:59:29 +02:00
|
|
|
$"OnlinePlayState: {Profile.OnlinePlayState}");
|
|
|
|
|
2018-08-15 00:02:42 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-26 00:59:29 +02:00
|
|
|
// UpdateUserPresence(nn::account::Uid, ulong Unknown0) -> buffer<Unknown1, type: 0x19, size: 0xe0>
|
2018-08-15 00:02:42 +02:00
|
|
|
public long UpdateUserPresence(ServiceCtx Context)
|
|
|
|
{
|
2018-10-07 15:13:46 +02:00
|
|
|
UInt128 Uuid = new UInt128(
|
2018-08-15 00:02:42 +02:00
|
|
|
Context.RequestData.ReadInt64(),
|
|
|
|
Context.RequestData.ReadInt64());
|
|
|
|
|
2018-09-26 00:59:29 +02:00
|
|
|
long Unknown0 = Context.RequestData.ReadInt64();
|
|
|
|
|
|
|
|
long Position = Context.Request.PtrBuff[0].Position;
|
|
|
|
long Size = Context.Request.PtrBuff[0].Size;
|
|
|
|
|
|
|
|
//Todo: Write the buffer content.
|
|
|
|
|
2018-10-07 15:13:46 +02:00
|
|
|
Context.Device.Log.PrintStub(LogClass.ServiceFriend, $"Stubbed. Uuid: {Uuid.ToString()} - " +
|
2018-09-26 00:59:29 +02:00
|
|
|
$"Unknown0: {Unknown0}");
|
2018-08-15 00:02:42 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-10 01:14:55 +01:00
|
|
|
}
|
2018-09-26 00:59:29 +02:00
|
|
|
}
|