2020-04-30 06:58:19 +02:00
|
|
|
using LibHac;
|
|
|
|
using LibHac.Bcat;
|
2021-12-23 17:55:50 +01:00
|
|
|
using LibHac.Common;
|
2020-04-30 06:58:19 +02:00
|
|
|
using System.Runtime.InteropServices;
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2019-09-19 02:45:11 +02:00
|
|
|
namespace Ryujinx.HLE.HOS.Services.Bcat.ServiceCreator
|
2018-07-23 16:20:16 +02:00
|
|
|
{
|
2021-06-29 19:37:13 +02:00
|
|
|
class IDeliveryCacheStorageService : DisposableIpcService
|
2018-07-23 16:20:16 +02:00
|
|
|
{
|
2021-12-23 17:55:50 +01:00
|
|
|
private SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> _base;
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2021-12-23 17:55:50 +01:00
|
|
|
public IDeliveryCacheStorageService(ServiceCtx context, ref SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService> baseService)
|
2020-04-30 06:58:19 +02:00
|
|
|
{
|
2021-12-23 17:55:50 +01:00
|
|
|
_base = SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheStorageService>.CreateMove(ref baseService);
|
2020-04-30 06:58:19 +02:00
|
|
|
}
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(0)]
|
2020-04-30 06:58:19 +02:00
|
|
|
// CreateFileService() -> object<nn::bcat::detail::ipc::IDeliveryCacheFileService>
|
|
|
|
public ResultCode CreateFileService(ServiceCtx context)
|
2019-09-10 11:55:28 +02:00
|
|
|
{
|
2021-12-23 17:55:50 +01:00
|
|
|
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheFileService>();
|
|
|
|
|
2023-03-02 03:42:27 +01:00
|
|
|
Result result = _base.Get.CreateFileService(ref service.Ref);
|
2020-04-30 06:58:19 +02:00
|
|
|
|
|
|
|
if (result.IsSuccess())
|
|
|
|
{
|
2023-03-02 03:42:27 +01:00
|
|
|
MakeObject(context, new IDeliveryCacheFileService(ref service.Ref));
|
2020-04-30 06:58:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ResultCode)result.Value;
|
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(1)]
|
2020-04-30 06:58:19 +02:00
|
|
|
// CreateDirectoryService() -> object<nn::bcat::detail::ipc::IDeliveryCacheDirectoryService>
|
|
|
|
public ResultCode CreateDirectoryService(ServiceCtx context)
|
|
|
|
{
|
2021-12-23 17:55:50 +01:00
|
|
|
using var service = new SharedRef<LibHac.Bcat.Impl.Ipc.IDeliveryCacheDirectoryService>();
|
|
|
|
|
2023-03-02 03:42:27 +01:00
|
|
|
Result result = _base.Get.CreateDirectoryService(ref service.Ref);
|
2020-04-30 06:58:19 +02:00
|
|
|
|
|
|
|
if (result.IsSuccess())
|
|
|
|
{
|
2023-03-02 03:42:27 +01:00
|
|
|
MakeObject(context, new IDeliveryCacheDirectoryService(ref service.Ref));
|
2020-04-30 06:58:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ResultCode)result.Value;
|
2019-09-10 11:55:28 +02:00
|
|
|
}
|
|
|
|
|
2023-04-15 01:00:34 +02:00
|
|
|
[CommandCmif(10)]
|
2019-09-10 11:55:28 +02:00
|
|
|
// EnumerateDeliveryCacheDirectory() -> (u32, buffer<nn::bcat::DirectoryName, 6>)
|
|
|
|
public ResultCode EnumerateDeliveryCacheDirectory(ServiceCtx context)
|
|
|
|
{
|
2022-10-05 01:12:54 +02:00
|
|
|
ulong bufferAddress = context.Request.ReceiveBuff[0].Position;
|
|
|
|
ulong bufferLen = context.Request.ReceiveBuff[0].Size;
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2022-10-05 01:12:54 +02:00
|
|
|
using (var region = context.Memory.GetWritableRegion(bufferAddress, (int)bufferLen, true))
|
|
|
|
{
|
|
|
|
Result result = _base.Get.EnumerateDeliveryCacheDirectory(out int count, MemoryMarshal.Cast<byte, DirectoryName>(region.Memory.Span));
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2022-10-05 01:12:54 +02:00
|
|
|
context.ResponseData.Write(count);
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2022-10-05 01:12:54 +02:00
|
|
|
return (ResultCode)result.Value;
|
|
|
|
}
|
2020-04-30 06:58:19 +02:00
|
|
|
}
|
2019-09-10 11:55:28 +02:00
|
|
|
|
2021-06-29 19:37:13 +02:00
|
|
|
protected override void Dispose(bool isDisposing)
|
2020-04-30 06:58:19 +02:00
|
|
|
{
|
2021-06-29 19:37:13 +02:00
|
|
|
if (isDisposing)
|
|
|
|
{
|
2021-12-23 17:55:50 +01:00
|
|
|
_base.Destroy();
|
2021-06-29 19:37:13 +02:00
|
|
|
}
|
2019-09-10 11:55:28 +02:00
|
|
|
}
|
2018-07-23 16:20:16 +02:00
|
|
|
}
|
2020-04-30 06:58:19 +02:00
|
|
|
}
|