[Applications.RPCPort] Add a new Parcel constructor (#4964)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Thu, 9 Feb 2023 00:34:34 +0000 (09:34 +0900)
committerGitHub <noreply@github.com>
Thu, 9 Feb 2023 00:34:34 +0000 (09:34 +0900)
* [Applications.Common] Modify Parcel constructor

The withoutHeader parameter is added to the Parcel constructor.
If it's true, the parcel object does not have the header.

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.RPCPort.cs
src/Tizen.Applications.Common/Tizen.Applications.RPCPort/Parcel.cs

index 4957f22..75d2179 100755 (executable)
@@ -177,6 +177,10 @@ internal static partial class Interop
             //int rpc_port_parcel_create_from_raw(rpc_port_parcel_h *h, const void *raw, unsigned int size);
             [DllImport(Libraries.RpcPort, EntryPoint = "rpc_port_parcel_create_from_raw")]
             internal static extern ErrorCode CreateFromRaw(out IntPtr parcelHandle, byte[] raw, uint size);
+
+            //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);
         }
 
         internal static partial class Proxy
index c1dd827..132b65b 100755 (executable)
@@ -158,13 +158,33 @@ namespace Tizen.Applications.RPCPort
         /// <summary>
         /// Constructor for this class.
         /// </summary>
+        /// <param name="withHeader">If it's false, the parcel object does not have the header.</param>
+        /// <exception cref="InvalidIOException">Thrown when an internal IO error occurs.</exception>
+        /// <since_tizen> 11 </since_tizen>
+        public Parcel(bool withHeader)
+        {
+            Interop.LibRPCPort.ErrorCode error;
+            if (withHeader)
+            {
+                error = Interop.LibRPCPort.Parcel.Create(out _handle);
+                if (error != Interop.LibRPCPort.ErrorCode.None)
+                    throw new InvalidIOException();
+            }
+            else
+            {
+                error = Interop.LibRPCPort.Parcel.CreateWithoutHeader(out _handle);
+                if (error != Interop.LibRPCPort.ErrorCode.None)
+                    throw new InvalidIOException();
+            }
+        }
+
+        /// <summary>
+        /// Constructor for this class.
+        /// </summary>
         /// <exception cref="InvalidIOException">Thrown when an internal IO error occurs.</exception>
         /// <since_tizen> 5 </since_tizen>
-        public Parcel()
+        public Parcel() : this(true)
         {
-            var r = Interop.LibRPCPort.Parcel.Create(out _handle);
-            if (r != Interop.LibRPCPort.ErrorCode.None)
-                throw new InvalidIOException();
         }
 
         /// <summary>