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 enum ServiceType
26 /// App-to-app communication service
31 /// Remote app-control service
36 internal static partial class ConvService
38 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_create")]
39 internal static extern int Create(out ConvServiceHandle /* conv_service_h */ handle);
41 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_clone")]
42 internal static extern int Clone(IntPtr /* conv_service_h */ originalHandle, out ConvServiceHandle /* conv_service_h */ targetHandle);
44 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_destroy")]
45 internal static extern int Destroy(IntPtr /* conv_service_h */ handle);
47 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_get_property_string")]
48 internal static extern int GetPropertyString(ConvServiceHandle /* conv_service_h */ handle, string key, out IntPtr value);
50 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_set_property_string")]
51 internal static extern int SetPropertyString(ConvServiceHandle /* conv_service_h */ handle, string key, string value);
53 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_get_type")]
54 internal static extern int GetType(IntPtr /* conv_service_h */ handle, out int /* conv_service_e */ value);
56 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_set_type")]
57 internal static extern int SetType(ConvServiceHandle /* conv_service_h */ handle, int /* conv_service_e */ value);
59 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_start")]
60 internal static extern int Start(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
62 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_read")]
63 internal static extern int Read(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
65 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_publish")]
66 internal static extern int Publish(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
68 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_stop")]
69 internal static extern int Stop(ConvServiceHandle /* conv_service_h */ handle, ConvChannelHandle channel, ConvPayloadHandle payload);
71 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_set_listener_cb")]
72 internal static extern int SetListenerCb(ConvServiceHandle /* conv_service_h */ handle, ConvServiceListenerCallback callback, IntPtr /* void */ userData);
74 [DllImport(Libraries.Convergence, EntryPoint = "conv_service_unset_listener_cb")]
75 internal static extern int UnsetListenerCb(ConvServiceHandle /* conv_service_h */ handle);
77 [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
78 internal delegate void ConvServiceListenerCallback(IntPtr /* conv_service_h */ serviceHandle, IntPtr channelHandle, int error, IntPtr result, IntPtr /* void */ userData);
81 internal class ConvServiceHandle : TizenSafeHandle
83 public ConvServiceHandle(): base()
88 public ConvServiceHandle(IntPtr handle)
93 public override void Destroy()
95 if (handle != IntPtr.Zero)
97 var err = ConvService.Destroy(this.handle);
98 if (err != (int)ConvErrorCode.None)
100 Log.Error(ErrorFactory.LogTag, "Failed to destroy conv service handle");
101 throw ErrorFactory.GetException(err);