aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Sdk/Friends/Detail/Ipc/ServiceCreator.cs
blob: 1be804dfd7e6ff53f5880722b0759cc1d8863a63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Account;
using Ryujinx.Horizon.Sdk.Sf;

namespace Ryujinx.Horizon.Sdk.Friends.Detail.Ipc
{
    partial class ServiceCreator : IServiceCreator
    {
        private readonly IEmulatorAccountManager _accountManager;
        private readonly NotificationEventHandler _notificationEventHandler;
        private readonly FriendsServicePermissionLevel _permissionLevel;

        public ServiceCreator(IEmulatorAccountManager accountManager, NotificationEventHandler notificationEventHandler, FriendsServicePermissionLevel permissionLevel)
        {
            _accountManager = accountManager;
            _notificationEventHandler = notificationEventHandler;
            _permissionLevel = permissionLevel;
        }

        [CmifCommand(0)]
        public Result CreateFriendService(out IFriendService friendService)
        {
            friendService = new FriendService(_accountManager, _permissionLevel);

            return Result.Success;
        }

        [CmifCommand(1)] // 2.0.0+
        public Result CreateNotificationService(out INotificationService notificationService, Uid userId)
        {
            if (userId.IsNull)
            {
                notificationService = null;

                return FriendResult.InvalidArgument;
            }

            notificationService = new NotificationService(_notificationEventHandler, userId, _permissionLevel);

            return Result.Success;
        }

        [CmifCommand(2)] // 4.0.0+
        public Result CreateDaemonSuspendSessionService(out IDaemonSuspendSessionService daemonSuspendSessionService)
        {
            daemonSuspendSessionService = new DaemonSuspendSessionService();

            return Result.Success;
        }
    }
}