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 CallPreferredVoiceSubsubscription PreferredVoiceSubscription
68 CallPreferredVoiceSubsubscription subs = CallPreferredVoiceSubsubscription.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 CallPreferredVoiceSubsubscription.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="InvalidOperationException">
90 /// This exception can occur due to one of the following reasons:
91 /// 1. Permission Denied
93 /// 3. Operation Failed
95 public List<CallHandle> GetCallHandleList()
98 _callList = new IntPtr();
100 TelephonyError error = Interop.Call.GetCallList(_handle, out count, out _callList);
101 if (error != TelephonyError.None)
103 Tizen.Log.Error(Interop.Telephony.LogTag, "GetCallList Failed with error " + error);
104 throw ExceptionFactory.CreateException(error);
110 IntPtr[] handleArray = new IntPtr[count];
111 Marshal.Copy(_callList, handleArray, 0, (int)count);
112 foreach (IntPtr handle in handleArray)
114 CallHandle info = new CallHandle(handle);
118 _safeCallList = new Interop.Call.SafeCallList(_callList, count);