Set Tizen API Version to Vconf
[platform/core/csapi/tizenfx.git] / src / Tizen.Convergence / Interop / Interop.Internal.Conv.Device.cs
1 // Copyright 2016 by Samsung Electronics, Inc.,
2 //
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.
8
9 using System;
10 using System.Runtime.InteropServices;
11 using Tizen;
12 using Tizen.Convergence;
13
14 internal static partial class Interop
15 {
16     internal static partial class Internal
17     {
18         internal static partial class ConvDevice
19         {
20             [DllImport(Libraries.Convergence, EntryPoint = "conv_device_clone")]
21             internal static extern int Clone(IntPtr /* conv_device_h */ originalHandle, out ConvDeviceHandle /* conv_device_h */ targetHandle);
22
23             [DllImport(Libraries.Convergence, EntryPoint = "conv_device_destroy")]
24             internal static extern int Destroy(IntPtr /* conv_device_h */ handle);
25
26             [DllImport(Libraries.Convergence, EntryPoint = "conv_device_get_property_string")]
27             internal static extern int GetPropertyString(ConvDeviceHandle /* conv_device_h */ handle, string key, out IntPtr value);
28
29             [DllImport(Libraries.Convergence, EntryPoint = "conv_device_foreach_service")]
30             internal static extern int ForeachService(ConvDeviceHandle /* conv_device_h */ handle, ConvServiceForeachCallback cb, IntPtr /* void */ userData);
31
32             [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
33             internal delegate void ConvServiceForeachCallback(IntPtr serviceHandle, IntPtr /* void */ userData);
34         }
35
36         internal class ConvDeviceHandle : TizenSafeHandle
37         {
38             public ConvDeviceHandle() : base()
39             {
40
41             }
42
43             public ConvDeviceHandle(IntPtr handle)
44                 : base(handle)
45             {
46             }
47
48             public override void Destroy()
49             {
50                 if (handle != IntPtr.Zero)
51                 {
52                     var err = ConvDevice.Destroy(this.handle);
53                     if (err != (int)ConvErrorCode.None)
54                     {
55                         Log.Error(ErrorFactory.LogTag, "Failed to destroy conv device handle");
56                         throw ErrorFactory.GetException(err);
57                     }
58                 }
59             }
60         }
61     }
62 }