1 // Copyright 2016 by Samsung Electronics, Inc.,
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
10 using System.Runtime.InteropServices;
12 using Tizen.Convergence;
14 internal static partial class Interop
16 internal static partial class Internal
18 internal static partial class ConvPayload
20 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_create")]
21 internal static extern int Create(out ConvPayloadHandle /* conv_payload_h */ handle);
23 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_destroy")]
24 internal static extern int Destroy(IntPtr /* conv_payload_h */ handle);
26 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_string")]
27 internal static extern int SetString(ConvPayloadHandle /* conv_payload_h */ handle, string key, string value);
29 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_string")]
30 internal static extern int GetString(ConvPayloadHandle /* conv_payload_h */ handle, string key, out IntPtr value);
32 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_byte")]
33 internal static extern int SetByte(ConvPayloadHandle /* conv_payload_h */ handle, string key, int length, byte[] value);
35 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_byte")]
36 internal static extern int GetByte(ConvPayloadHandle /* conv_payload_h */ handle, string key, out int length, out IntPtr value);
38 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_set_binary")]
39 internal static extern int SetBinary(ConvPayloadHandle /* conv_payload_h */ handle, int length, byte[] value);
41 [DllImport(Libraries.Convergence, EntryPoint = "conv_payload_get_binary")]
42 internal static extern int GetBinary(ConvPayloadHandle /* conv_payload_h */ handle, out int length, out IntPtr value);
45 internal class ConvPayloadHandle : TizenSafeHandle
47 private bool _ownsHandle = true;
49 public ConvPayloadHandle(): base()
54 public ConvPayloadHandle(IntPtr handle)
59 public ConvPayloadHandle(IntPtr handle, bool ownsHandle)
62 _ownsHandle = ownsHandle;
65 public override void Destroy()
67 if (_ownsHandle && handle != IntPtr.Zero)
69 var err = ConvPayload.Destroy(this.handle);
70 if (err != (int)ConvErrorCode.None)
72 Log.Error(ErrorFactory.LogTag, "Failed to destroy conv payload handle");
73 throw ErrorFactory.GetException(err);