2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
19 using System.Runtime.InteropServices;
20 using static Interop.Telephony;
22 namespace Tizen.Telephony
25 /// The Call API's allows you to get the voice and video call states.
26 /// It provides the List of CallHandle which can be used to get the information about call related actions.
30 internal IntPtr _handle;
31 private List<IntPtr> _callHandle = new List<IntPtr>();
32 private List<CallHandle> _list = new List<CallHandle>();
33 private IntPtr _callList;
34 private Interop.Call.SafeCallList _safeCallList;
37 /// Public Constructor
39 /// <param name="handle">
40 /// SlotHandle received in the Manager.Init API
42 /// <exception cref="ArgumentNullException">
43 /// This exception occurs if handle provided is null
45 public Call(SlotHandle handle)
49 throw new ArgumentNullException();
52 _handle = handle._handle;
56 /// Gets the current value for the preferred voice call subscription.
59 /// http://tizen.org/privilege/telephony
62 /// The currently set preferred voicecall subscription value.
64 public CallPreferredVoiceSubscription PreferredVoiceSubscription
68 CallPreferredVoiceSubscription subs = CallPreferredVoiceSubscription.Unknown;
69 TelephonyError error = Interop.Call.GetPreferredVoiceSubscription(_handle, out subs);
70 if (error != TelephonyError.None)
72 Tizen.Log.Error(Interop.Telephony.LogTag, "GetPreferredVoiceSubscription Failed with error " + error);
73 return CallPreferredVoiceSubscription.Unknown;
81 /// Gets the list of the current call.
84 /// http://tizen.org/privilege/telephony
87 /// List of CallHandle for existing calls.
89 /// <exception cref="ArgumentException">Incase of Invalid parameter</exception>
90 /// <exception cref="InvalidOperationException">Incase of any System error</exception>
91 /// <exception cref="UnauthorizedAccessException">Incase of Privileges are not defined</exception>
92 /// <exception cref="NotSupportedException">Incase of Telephony is not supported</exception>>
93 /// <exception cref="OutOfMemoryException">Incase of Out of Memory</exception>>
94 public List<CallHandle> GetCallHandleList()
97 _callList = new IntPtr();
99 TelephonyError error = Interop.Call.GetCallList(_handle, out count, out _callList);
100 if (error != TelephonyError.None)
102 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallList Failed with error " + error);
103 throw ExceptionFactory.CreateException(error);
109 IntPtr[] handleArray = new IntPtr[count];
110 Marshal.Copy(_callList, handleArray, 0, (int)count);
111 foreach (IntPtr handle in handleArray)
113 CallHandle info = new CallHandle(handle);
117 _safeCallList = new Interop.Call.SafeCallList(_callList, count);