2019-07-04 09:14:17 -06:00
|
|
|
using Ryujinx.Common;
|
2018-08-16 17:47:36 -06:00
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
2019-06-16 17:08:32 -06:00
|
|
|
using Ryujinx.HLE.Utilities;
|
2018-02-09 17:14:55 -07:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
2019-06-27 06:05:30 -06:00
|
|
|
using static Ryujinx.HLE.HOS.ErrorCode;
|
|
|
|
|
2018-08-16 17:47:36 -06:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Friend
|
2018-02-09 17:14:55 -07:00
|
|
|
{
|
2019-07-10 09:59:54 -06:00
|
|
|
[Service("friend:a", FriendServicePermissionLevel.Admin)]
|
|
|
|
[Service("friend:m", FriendServicePermissionLevel.Manager)]
|
|
|
|
[Service("friend:s", FriendServicePermissionLevel.System)]
|
|
|
|
[Service("friend:u", FriendServicePermissionLevel.User)]
|
|
|
|
[Service("friend:v", FriendServicePermissionLevel.Overlay)]
|
2018-04-05 22:01:52 -06:00
|
|
|
class IServiceCreator : IpcService
|
2018-02-09 17:14:55 -07:00
|
|
|
{
|
2019-07-04 09:14:17 -06:00
|
|
|
private FriendServicePermissionLevel _permissionLevel;
|
|
|
|
|
2019-07-10 09:59:54 -06:00
|
|
|
private Dictionary<int, ServiceProcessRequest> _commands;
|
|
|
|
|
2018-12-06 04:16:24 -07:00
|
|
|
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
|
2018-02-09 17:14:55 -07:00
|
|
|
|
2019-07-10 09:59:54 -06:00
|
|
|
public IServiceCreator(ServiceCtx context, FriendServicePermissionLevel permissionLevel)
|
2018-02-09 17:14:55 -07:00
|
|
|
{
|
2018-12-06 04:16:24 -07:00
|
|
|
_commands = new Dictionary<int, ServiceProcessRequest>
|
2018-02-09 17:14:55 -07:00
|
|
|
{
|
2019-06-16 17:08:32 -06:00
|
|
|
{ 0, CreateFriendService },
|
|
|
|
{ 1, CreateNotificationService }, // 2.0.0+
|
|
|
|
{ 2, CreateDaemonSuspendSessionService }, // 4.0.0+
|
2018-02-09 17:14:55 -07:00
|
|
|
};
|
2019-07-04 09:14:17 -06:00
|
|
|
|
|
|
|
_permissionLevel = permissionLevel;
|
2018-02-09 17:14:55 -07:00
|
|
|
}
|
|
|
|
|
2019-06-16 17:08:32 -06:00
|
|
|
// CreateFriendService() -> object<nn::friends::detail::ipc::IFriendService>
|
2019-07-04 09:14:17 -06:00
|
|
|
public long CreateFriendService(ServiceCtx context)
|
2018-02-09 17:14:55 -07:00
|
|
|
{
|
2019-07-04 09:14:17 -06:00
|
|
|
MakeObject(context, new IFriendService(_permissionLevel));
|
2018-02-24 21:34:16 -07:00
|
|
|
|
2018-02-09 17:14:55 -07:00
|
|
|
return 0;
|
|
|
|
}
|
2019-06-16 17:08:32 -06:00
|
|
|
|
|
|
|
// CreateNotificationService(nn::account::Uid) -> object<nn::friends::detail::ipc::INotificationService>
|
2019-07-04 09:14:17 -06:00
|
|
|
public long CreateNotificationService(ServiceCtx context)
|
2019-06-16 17:08:32 -06:00
|
|
|
{
|
2019-07-04 09:14:17 -06:00
|
|
|
UInt128 userId = context.RequestData.ReadStruct<UInt128>();
|
2019-06-16 17:08:32 -06:00
|
|
|
|
2019-06-27 06:05:30 -06:00
|
|
|
if (userId.IsNull)
|
|
|
|
{
|
2019-07-04 09:14:17 -06:00
|
|
|
return MakeError(ErrorModule.Friends, FriendError.InvalidArgument);
|
2019-06-27 06:05:30 -06:00
|
|
|
}
|
|
|
|
|
2019-07-04 09:14:17 -06:00
|
|
|
MakeObject(context, new INotificationService(context, userId, _permissionLevel));
|
2019-06-16 17:08:32 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateDaemonSuspendSessionService() -> object<nn::friends::detail::ipc::IDaemonSuspendSessionService>
|
2019-07-04 09:14:17 -06:00
|
|
|
public long CreateDaemonSuspendSessionService(ServiceCtx context)
|
2019-06-16 17:08:32 -06:00
|
|
|
{
|
2019-07-04 09:14:17 -06:00
|
|
|
MakeObject(context, new IDaemonSuspendSessionService(_permissionLevel));
|
2019-06-16 17:08:32 -06:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-02-09 17:14:55 -07:00
|
|
|
}
|
2019-06-27 06:05:30 -06:00
|
|
|
}
|