|
|
@@ -1,32 +1,69 @@
|
|
|
using Ryujinx.Common.Logging;
|
|
|
+using Ryujinx.HLE.HOS.Services.Arp;
|
|
|
+using System;
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
|
|
{
|
|
|
class IParentalControlService : IpcService
|
|
|
{
|
|
|
- private bool _initialized = false;
|
|
|
+ private int _permissionFlag;
|
|
|
+ private ulong _titleId;
|
|
|
+ private bool _freeCommunicationEnabled;
|
|
|
+ private int[] _ratingAge;
|
|
|
|
|
|
- private bool _needInitialize;
|
|
|
-
|
|
|
- public IParentalControlService(bool needInitialize = true)
|
|
|
+ public IParentalControlService(ServiceCtx context, bool withInitialize, int permissionFlag)
|
|
|
{
|
|
|
- _needInitialize = needInitialize;
|
|
|
+ _permissionFlag = permissionFlag;
|
|
|
+
|
|
|
+ if (withInitialize)
|
|
|
+ {
|
|
|
+ Initialize(context);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
[Command(1)] // 4.0.0+
|
|
|
// Initialize()
|
|
|
public ResultCode Initialize(ServiceCtx context)
|
|
|
{
|
|
|
- if (_needInitialize && !_initialized)
|
|
|
+ if ((_permissionFlag & 0x8001) == 0)
|
|
|
{
|
|
|
- _initialized = true;
|
|
|
+ return ResultCode.PermissionDenied;
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ ResultCode resultCode = ResultCode.InvalidPid;
|
|
|
+
|
|
|
+ if (context.Process.Pid != 0)
|
|
|
{
|
|
|
- Logger.PrintWarning(LogClass.ServicePctl, "Service is already initialized!");
|
|
|
+ if ((_permissionFlag & 0x40) == 0)
|
|
|
+ {
|
|
|
+ ulong titleId = ApplicationLaunchProperty.GetByPid(context).TitleId;
|
|
|
+
|
|
|
+ if (titleId != 0)
|
|
|
+ {
|
|
|
+ _titleId = titleId;
|
|
|
+
|
|
|
+ // TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields.
|
|
|
+ _ratingAge = Array.ConvertAll(context.Device.System.ControlData.Value.RatingAge.ToArray(), Convert.ToInt32);
|
|
|
+ _freeCommunicationEnabled = context.Device.System.ControlData.Value.ParentalControl == LibHac.Ns.ParentalControlFlagValue.FreeCommunication;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_titleId != 0)
|
|
|
+ {
|
|
|
+ // TODO: Service store some private fields in another static object.
|
|
|
+
|
|
|
+ if ((_permissionFlag & 0x8040) == 0)
|
|
|
+ {
|
|
|
+ // TODO: Service store TitleId and FreeCommunicationEnabled in another static object.
|
|
|
+ // When it's done it signal an event in this static object.
|
|
|
+ Logger.PrintStub(LogClass.ServicePctl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ resultCode = ResultCode.Success;
|
|
|
}
|
|
|
|
|
|
- return ResultCode.Success;
|
|
|
+ return resultCode;
|
|
|
}
|
|
|
|
|
|
[Command(1001)]
|
|
|
@@ -35,6 +72,11 @@ namespace Ryujinx.HLE.HOS.Services.Pctl.ParentalControlServiceFactory
|
|
|
{
|
|
|
Logger.PrintStub(LogClass.ServicePctl);
|
|
|
|
|
|
+ if (!_freeCommunicationEnabled)
|
|
|
+ {
|
|
|
+ return ResultCode.FreeCommunicationDisabled;
|
|
|
+ }
|
|
|
+
|
|
|
return ResultCode.Success;
|
|
|
}
|
|
|
}
|