diff --git a/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs b/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs index 75d21798bde..19fdc6c2f37 100755 --- a/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs @@ -181,6 +181,34 @@ internal static partial class Parcel //int rpc_port_parcel_create_without_header(rpc_port_parcel_h *h); [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_create_without_header")] internal static extern ErrorCode CreateWithoutHeader(out IntPtr parcelHandle); + + //int rpc_port_parcel_reserve(rpc_port_parcel_h h, unsigned int size); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_reserve")] + internal static extern ErrorCode Reserve(IntPtr parcelHandle, uint size); + + //int rpc_port_parcel_set_data_size(rpc_port_parcel_h h, unsigned int size); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_set_data_size")] + internal static extern ErrorCode SetDataSize(IntPtr parcelHandle, uint size); + + //int rpc_port_parcel_get_data_size(rpc_port_parcel_h h, unsigned int* size); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_get_data_size")] + internal static extern ErrorCode GetDataSize(IntPtr parcelHandle, out uint size); + + //int rpc_port_parcel_pin(rpc_port_parcel_h h); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_pin")] + internal static extern ErrorCode Pin(IntPtr parcelHandle); + + //int rpc_port_parcel_get_reader(rpc_port_parcel_h h, unsigned int* reader_pos); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_get_reader")] + internal static extern ErrorCode GetReader(IntPtr parcelHandle, out uint readerPos); + + //int rpc_port_parcel_set_reader(rpc_port_parcel_h h, unsigned int reader_pos); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_set_reader")] + internal static extern ErrorCode SetReader(IntPtr parcelHandle, uint readerPos); + + //int rpc_port_parcel_create_from_parcel(rpc_port_parcel_h* h, rpc_port_parcel_h origin_parcel, unsigned int start_pos, unsigned int size); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_create_from_parcel")] + internal static extern ErrorCode CreateFromParcel(out IntPtr parcelHandle, IntPtr originParcel, uint startPos, uint size); } internal static partial class Proxy diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs index ce0aada91db..15acd882d41 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs @@ -15,6 +15,8 @@ */ using System; +using System.ComponentModel; +using System.Reflection.Metadata; using System.Runtime.InteropServices; namespace Tizen.Applications.RPCPort @@ -155,6 +157,28 @@ public class Parcel : IDisposable private IntPtr _handle; private ParcelHeader _header; + /// + /// Constructs a sub parcel from origin parcel. + /// + /// The origin parcel. + /// The start position from origin parcel. + /// The size of the new parcel. + /// Thrown when an internal IO error occurs. + /// Thrown when arguments are invalid. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public Parcel(Parcel origin, uint startPos, uint size) + { + if (origin == null) + throw new ArgumentException(); + + Interop.LibRPCPort.ErrorCode error; + + error = Interop.LibRPCPort.Parcel.CreateFromParcel(out _handle, origin._handle, startPos, size); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + /// /// Constructs a new instance of the Parcel class. /// @@ -529,6 +553,98 @@ public ParcelHeader GetHeader() return _header; } + /// + /// Reserves bytes to write later. + /// The bytes to reserve. + /// + /// Thrown when an internal IO error occurs. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public void Reserve(uint size) + { + Interop.LibRPCPort.ErrorCode error; + error = Interop.LibRPCPort.Parcel.Reserve(_handle, size); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + + /// + /// Pin the memory. Once it is called, the capacity would not be changed. + /// + /// Thrown when an internal IO error occurs. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public void Pin() + { + Interop.LibRPCPort.ErrorCode error; + error = Interop.LibRPCPort.Parcel.Pin(_handle); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + + /// + /// Gets the reader pointer of the parcel to the start. + /// + /// The position of the reader + /// Thrown when an internal IO error occurs. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetReader() + { + Interop.LibRPCPort.ErrorCode error; + error = Interop.LibRPCPort.Parcel.GetReader(_handle, out uint reader); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + return reader; + } + + /// + /// Sets the reader pointer of the parcel to the start. + /// + /// The position to read. + /// Thrown when an internal IO error occurs. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetReader(uint pos) + { + Interop.LibRPCPort.ErrorCode error; + error = Interop.LibRPCPort.Parcel.SetReader(_handle, pos); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + + /// + /// Gets the size of the raw data of the parcel. + /// + /// The size of data + /// Thrown when an internal IO error occurs. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public uint GetDataSize() + { + Interop.LibRPCPort.ErrorCode error; + error = Interop.LibRPCPort.Parcel.GetDataSize(_handle, out uint size); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + + return size; + } + + /// + /// Sets the size of the raw data of the parcel. + /// + /// The size of data. + /// Thrown when an internal IO error occurs. + /// 10 + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetDataSize(uint size) + { + Interop.LibRPCPort.ErrorCode error; + error = Interop.LibRPCPort.Parcel.SetDataSize(_handle, size); + if (error != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + #region IDisposable Support private bool disposedValue = false;