From: ChangGyu Choi Date: Mon, 27 Sep 2021 07:29:02 +0000 (+0900) Subject: [Tizen.Applications.RPCPort] Add RPCPort ParcelHeader internal APIs (#3612) X-Git-Tag: accepted/tizen/6.0/unified/20210928.125133~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=34662ae79c55e7d5b29756594e11b0396efdd544;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Tizen.Applications.RPCPort] Add RPCPort ParcelHeader internal APIs (#3612) * [Tizen.Applications.RPCPort] Add RPCPort ParcelHeader internal APIs Adds: class: - Tizen.Applications.RPCPort.Parcel.Header Operation: - Tizen.Applications.RPCPort.Disconnect() - Tizen.Applications.RPCPort.Parcel.GetHeader() - Tizen.Applications.RPCPort.Parcel.Header.SetTag() - Tizen.Applications.RPCPort.Parcel.Header.GetTag() - Tizen.Applications.RPCPort.Parcel.Header.SetSeqNum() - Tizen.Applications.RPCPort.Parcel.Header.GetSeqNum() - Tizen.Applications.RPCPort.Parcel.Header.GetTimeStamp() Signed-off-by: ChangGyu Choi * Fix tizen version description from 9 to 8 Signed-off-by: ChangGyu Choi --- diff --git a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs index 825599e..55d23c9 100644 --- a/src/Tizen.Applications.Common/Interop/Interop.Libc.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.Libc.cs @@ -17,11 +17,21 @@ using System; using System.Runtime.InteropServices; +using Tizen.Internals; + internal static partial class Interop { internal static partial class Libc { [DllImport(Libraries.Libc, EntryPoint = "free", CallingConvention = CallingConvention.Cdecl)] internal static extern int Free(IntPtr ptr); + + [NativeStruct("struct timespec", Include = "time.h")] + [StructLayout(LayoutKind.Sequential)] + internal struct TimeStamp + { + public IntPtr sec; + public IntPtr nsec; + } } } diff --git a/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs b/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs index cfd4a21..e4d2728 100755 --- a/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs @@ -145,6 +145,30 @@ internal static partial class Interop //int rpc_port_parcel_burst_write(rpc_port_parcel_h h, const unsigned char *buf, unsigned int size); [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_burst_write")] internal static extern ErrorCode Write(IntPtr parcelHandle, byte[] buf, int size); + + //int rpc_port_parcel_get_header(rpc_port_parcel_h h, rpc_port_parcel_header_h *header); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_get_header")] + internal static extern ErrorCode GetHeader(IntPtr parcelHandle, out IntPtr ParcelHeaderHandle); + + //int rpc_port_parcel_header_set_tag(rpc_port_parcel_header_h header, const char *tag); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_header_set_tag")] + internal static extern ErrorCode SetTag(IntPtr parcelHeaderHandle, string tag); + + //int rpc_port_parcel_header_get_tag(rpc_port_parcel_header_h header, char **tag); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_header_get_tag")] + internal static extern ErrorCode GetTag(IntPtr parcelHeaderHandle, out string tag); + + //int rpc_port_parcel_header_set_seq_num(rpc_port_parcel_header_h header, int seq_num); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_header_set_seq_num")] + internal static extern ErrorCode SetSeqNum(IntPtr parcelHeaderHandle, int seq_num); + + //int rpc_port_parcel_header_get_seq_num(rpc_port_parcel_header_h header, int *seq_num); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_header_get_seq_num")] + internal static extern ErrorCode GetSeqNum(IntPtr parcelHeaderHandle, out int seq_num); + + //int rpc_port_parcel_header_get_timestamp(rpc_port_parcel_header_h header, struct timespec *timestamp); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_header_get_timestamp")] + internal static extern ErrorCode GetTimeStamp(IntPtr parcelHeaderHandle, ref Libc.TimeStamp time); } internal static partial class Proxy @@ -266,6 +290,10 @@ internal static partial class Interop //int rpc_port_unset_private_sharing(rpc_port_h port); [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_unset_private_sharing")] internal static extern ErrorCode UnsetPrivateSharing(IntPtr handle); + + //int rpc_port_disconnect(rpc_port_h h); + [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_disconnect")] + internal static extern ErrorCode Disconnect(IntPtr handle); } } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs index 2571d86..85830a5 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs @@ -15,16 +15,147 @@ */ using System; +using System.ComponentModel; namespace Tizen.Applications.RPCPort { /// + /// This structure represents the time stamp.(internal) + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public class TimeStamp + { + /// + /// Constructor with TimeStamp. + /// + /// 8 + internal TimeStamp(long second, long nanoSecond) + { + this.Second = second; + this.NanoSecond = nanoSecond; + } + + /// + /// The second of TimeStamp. + /// + /// 8 + public long Second + { + get; + private set; + } + + /// + /// The nano second of TimeStamp. + /// + /// 8 + public long NanoSecond + { + get; + private set; + } + } + + /// + /// The class is the header that has the Parcel's information.(internal) + /// + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public class ParcelHeader + { + internal IntPtr _handle; + + /// + /// Constructor with Header + /// + /// 8 + internal ParcelHeader() + { + } + + /// + /// Sets tag of Header. + /// + /// The tag of Header + /// Thrown when an internal IO error occurs. + /// 8 + public void SetTag(string tag) + { + var r = Interop.LibRPCPort.Parcel.SetTag(_handle, tag); + if (r != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + + /// + /// Gets tag of Header. + /// + /// Tag + /// Thrown when an internal IO error occurs. + /// 8 + public string GetTag() + { + var r = Interop.LibRPCPort.Parcel.GetTag(_handle, out string tag); + if (r != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + + return tag; + } + + /// + /// Sets sequence number of Header. + /// + /// The seqence number of Header + /// Thrown when an internal IO error occurs. + /// 8 + public void SetSequenceNumber(int sequenceNumber) + { + var r = Interop.LibRPCPort.Parcel.SetSeqNum(_handle, sequenceNumber); + if (r != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + } + + /// + /// Gets sequence number of Header. + /// + /// Sequence number + /// Thrown when an internal IO error occurs. + /// 8 + public int GetSequenceNumber() + { + var r = Interop.LibRPCPort.Parcel.GetSeqNum(_handle, out int sequenceNumber); + if (r != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + + return sequenceNumber; + } + + /// + /// Gets time stamp of Header. + /// + /// Time stamp + /// Thrown when an internal IO error occurs. + /// 8 + public TimeStamp GetTimeStamp() + { + Interop.Libc.TimeStamp time = new Interop.Libc.TimeStamp(); + + var r = Interop.LibRPCPort.Parcel.GetTimeStamp(_handle, ref time); + if (r != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidIOException(); + + return new TimeStamp(time.sec.ToInt64(), time.nsec.ToInt64()); + } + }; + + /// /// The class that helps to perform marshalling and unmarshalling for RPC. /// /// 5 public class Parcel : IDisposable { private IntPtr _handle; + private ParcelHeader _header; /// /// Constructor for this class. @@ -302,6 +433,24 @@ namespace Tizen.Applications.RPCPort return ret; } + /// + /// Gets header of rpc port parcel.(internal) + /// + /// Parcel header + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public ParcelHeader GetHeader() + { + if (_header == null) { + Interop.LibRPCPort.Parcel.GetHeader(_handle, out IntPtr handle); + _header = new ParcelHeader() { + _handle = handle + }; + } + + return _header; + } + #region IDisposable Support private bool disposedValue = false; diff --git a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs index a8eca4c..23e09f5 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Port.cs @@ -15,6 +15,7 @@ */ using System; +using System.ComponentModel; using System.Collections.Generic; using System.Linq; @@ -96,5 +97,18 @@ namespace Tizen.Applications.RPCPort if (err != Interop.LibRPCPort.ErrorCode.None) throw new InvalidIOException(); } + + /// + /// Disconnects the port.(internal) + /// + /// Thrown when an internal IO error occurrs. + /// 8 + [EditorBrowsable(EditorBrowsableState.Never)] + public void Disconnect() + { + Interop.LibRPCPort.ErrorCode err = Interop.LibRPCPort.Port.Disconnect(Handle); + if (err != Interop.LibRPCPort.ErrorCode.None) + throw new InvalidOperationException(); + } } }