/
Call.cs
125 lines (116 loc) · 4.86 KB
/
Call.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using static Interop.Telephony;
namespace Tizen.Telephony
{
/// <summary>
/// The Call APIs allow you to get the voice and video call states.
/// It provides the list of CallHandle which can be used to get the information about call related actions.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public class Call
{
internal IntPtr _handle;
private List<IntPtr> _callHandle = new List<IntPtr>();
private List<CallHandle> _list = new List<CallHandle>();
private IntPtr _callList;
private Interop.Call.SafeCallList _safeCallList;
/// <summary>
/// The public constructor.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <param name="handle">
/// SlotHandle received in the Manager.Init API.
/// </param>
/// <feature>http://tizen.org/feature/network.telephony</feature>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="ArgumentNullException">
/// This exception occurs if the handle provided is null.
/// </exception>
public Call(SlotHandle handle)
{
if (handle == null)
{
throw new ArgumentNullException();
}
_handle = handle._handle;
}
/// <summary>
/// Gets the current value for the preferred voice call subscription.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <privilege>http://tizen.org/privilege/telephony</privilege>
/// <value>
/// The currently set preferred voicecall subscription value.
/// </value>
public CallPreferredVoiceSubscription PreferredVoiceSubscription
{
get
{
CallPreferredVoiceSubscription subs = CallPreferredVoiceSubscription.Unknown;
TelephonyError error = Interop.Call.GetPreferredVoiceSubscription(_handle, out subs);
if (error != TelephonyError.None)
{
Tizen.Log.Error(Interop.Telephony.LogTag, "GetPreferredVoiceSubscription Failed with error " + error);
return CallPreferredVoiceSubscription.Unknown;
}
return subs;
}
}
/// <summary>
/// Gets the list of the current call.
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <returns>
/// The list of the CallHandle for existing calls.
/// </returns>
/// <privilege>http://tizen.org/privilege/telephony</privilege>
/// <feature>http://tizen.org/feature/network.telephony</feature>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="ArgumentException">In case of an invalid parameter.</exception>
/// <exception cref="InvalidOperationException">In case of any system error.</exception>
/// <exception cref="UnauthorizedAccessException">In case of privileges not defined.</exception>
/// <exception cref="OutOfMemoryException">In case of out of memory.</exception>
public IEnumerable<CallHandle> GetCallHandleList()
{
uint count;
_callList = new IntPtr();
_list.Clear();
TelephonyError error = Interop.Call.GetCallList(_handle, out count, out _callList);
if (error != TelephonyError.None)
{
Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallList Failed with error " + error);
throw ExceptionFactory.CreateException(error);
}
_callHandle.Clear();
if (count > 0)
{
IntPtr[] handleArray = new IntPtr[count];
Marshal.Copy(_callList, handleArray, 0, (int)count);
foreach (IntPtr handle in handleArray)
{
CallHandle info = new CallHandle(handle);
_list.Add(info);
}
_safeCallList = new Interop.Call.SafeCallList(_callList, count);
}
return _list;
}
}
}