Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Telephony / Interop / Interop.Call.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.Telephony;
20 using static Tizen.Telephony.CallHandle;
21
22 /// <summary>
23 /// Partial Interop Class
24 /// </summary>
25 internal static partial class Interop
26 {
27     /// <summary>
28     /// Call Interop Class
29     /// </summary>
30     internal static partial class Call
31     {
32         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_preferred_voice_subscription")]
33         internal static extern Telephony.TelephonyError GetPreferredVoiceSubscription(IntPtr handle, out CallPreferredVoiceSubscription callSub);
34
35         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_call_list")]
36         internal static extern Telephony.TelephonyError GetCallList(IntPtr handle, out uint count, out IntPtr callList);
37
38         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_release_call_list")]
39         internal static extern Telephony.TelephonyError ReleaseCallList(uint count, IntPtr callList);
40
41         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_handle_id")]
42         internal static extern Telephony.TelephonyError GetHandleId(IntPtr callHandle, out uint handleId);
43
44         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_number")]
45         internal static extern Telephony.TelephonyError GetNumber(IntPtr callHandle, out string number);
46
47         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_type")]
48         internal static extern Telephony.TelephonyError GetType(IntPtr callHandle, out CallType type);
49
50         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_status")]
51         internal static extern Telephony.TelephonyError GetStatus(IntPtr callHandle, out CallStatus status);
52
53         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_direction")]
54         internal static extern Telephony.TelephonyError GetDirection(IntPtr callHandle, out CallDirection direction);
55
56         [DllImport(Libraries.Telephony, EntryPoint = "telephony_call_get_conference_status")]
57         internal static extern Telephony.TelephonyError GetConferenceStatus(IntPtr callHandle, out bool conferenceStatus);
58
59         internal sealed class SafeCallList : SafeHandle
60         {
61             public SafeCallList()
62                 : base(IntPtr.Zero, true)
63             {
64             }
65
66             public SafeCallList(IntPtr handle, uint count)
67                 : base(handle, true)
68             {
69                 Count = count;
70             }
71
72             public override bool IsInvalid
73             {
74                 get { return this.handle == IntPtr.Zero; }
75             }
76
77             protected override bool ReleaseHandle()
78             {
79                 ReleaseCallList(Count, this.handle);
80                 this.SetHandle(IntPtr.Zero);
81                 return true;
82             }
83
84             internal uint Count;
85         }
86     }
87 }