[Build] Disable struct validation by default (#1746)
[platform/core/csapi/tizenfx.git] / src / Tizen.Telephony / Interop / Interop.Telephony.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.Internals;
20 using Tizen.Telephony;
21
22 /// <summary>
23 /// The Partial Interop class.
24 /// </summary>
25 internal static partial class Interop
26 {
27     /// <summary>
28     /// The Telephony Interop class.
29     /// </summary>
30     internal static class Telephony
31   {
32     private const int TIZEN_ERROR_TELEPHONY = -0x02600000;
33     internal static string LogTag = "Tizen.Telephony";
34     internal enum TelephonyError
35     {
36       None = Tizen.Internals.Errors.ErrorCode.None,
37       OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
38       InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
39       PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
40       NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
41       OperationFailed = TIZEN_ERROR_TELEPHONY | 0x0001,
42       SIMNotAvailable = TIZEN_ERROR_TELEPHONY | 0x1001
43     };
44
45 #if !PROFILE_TV
46     [NativeStruct("telephony_handle_list_s", Include="telephony_common.h", PkgConfig="capi-telephony")]
47 #endif
48     [StructLayout(LayoutKind.Sequential)]
49     internal struct HandleList
50     {
51       internal uint Count;
52       internal IntPtr HandleArrayPointer;
53     };
54
55     [DllImport(Libraries.Telephony, EntryPoint = "telephony_set_noti_cb")]
56     internal static extern TelephonyError TelephonySetNotiCb(IntPtr handle, Tizen.Telephony.ChangeNotificationEventArgs.Notification notiId, NotificationCallback cb, IntPtr userData);
57
58     [DllImport(Libraries.Telephony, EntryPoint = "telephony_unset_noti_cb")]
59     internal static extern TelephonyError TelephonyUnsetNotiCb(IntPtr handle, Tizen.Telephony.ChangeNotificationEventArgs.Notification notiId);
60
61     [DllImport(Libraries.Telephony, EntryPoint = "telephony_init")]
62     internal static extern TelephonyError TelephonyInit(out HandleList list);
63
64     [DllImport(Libraries.Telephony, EntryPoint = "telephony_deinit")]
65     internal static extern TelephonyError TelephonyDeinit(ref HandleList list);
66
67     [DllImport(Libraries.Telephony, EntryPoint = "telephony_get_state")]
68     internal static extern TelephonyError TelephonyGetState(out State state);
69
70     [DllImport(Libraries.Telephony, EntryPoint = "telephony_set_state_changed_cb")]
71     internal static extern TelephonyError TelephonySetStateChangedCb(StateChangedCallback callback, IntPtr userData);
72
73     [DllImport(Libraries.Telephony, EntryPoint = "telephony_unset_state_changed_cb")]
74     internal static extern TelephonyError TelephonyUnsetStateChangedCb(StateChangedCallback callback);
75
76     [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
77     internal delegate void NotificationCallback(IntPtr handle, ChangeNotificationEventArgs.Notification notiId, IntPtr data, IntPtr userData);
78
79     [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
80     internal delegate void StateChangedCallback(State state, IntPtr userData);
81   }
82 }