[Tapi] Implementation of Ss APIs.
authoradhavan.m <adhavan.m@samsung.com>
Wed, 21 Jun 2017 07:49:09 +0000 (13:19 +0530)
committeradhavan.m <adhavan.m@samsung.com>
Thu, 22 Jun 2017 06:34:11 +0000 (12:04 +0530)
Change-Id: Ia6f4e092f663b28c51afb862f3a7fa43774cae1e
Signed-off-by: adhavan.m <adhavan.m@samsung.com>
src/Tizen.Tapi/Tizen.Tapi/Ss.cs [new file with mode: 0755]
src/Tizen.Tapi/Tizen.Tapi/SsData.cs
src/Tizen.Tapi/Tizen.Tapi/SsEnumerations.cs
src/Tizen.Tapi/Tizen.Tapi/SsStructs.cs

diff --git a/src/Tizen.Tapi/Tizen.Tapi/Ss.cs b/src/Tizen.Tapi/Tizen.Tapi/Ss.cs
new file mode 100755 (executable)
index 0000000..dd283db
--- /dev/null
@@ -0,0 +1,524 @@
+/*
+ * 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.Threading.Tasks;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Tizen.Tapi
+{
+    /// <summary>
+    /// A class which manages Supplementary Services of the SIM.
+    /// </summary>
+    public class Ss
+    {
+        private IntPtr _handle = IntPtr.Zero;
+        private Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback> _callbackMap = new Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback>();
+        private int _requestId = 0;
+        private Ss()
+        {
+        }
+
+        /// <summary>
+        /// A constructor to instantiate Ss class using the Tapi handle.
+        /// </summary>
+        /// <param name="handle">An instance of TapiHandle obtained from InitTapi in TapiManager API.</param>
+        /// <exception cref="ArgumentNullException">Thrown when handle is passed as null.</exception>
+        public Ss(TapiHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException("Handle is null");
+            }
+
+            _handle = handle._handle;
+        }
+
+        /// <summary>
+        /// Sends a request to activate/deactivate call barring.
+        /// </summary>
+        /// <param name="info">The information about call barring.</param>
+        /// <returns>A task containing an instance of SsBarringResponse which contains information about barring response.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privlevel>platform</privlevel>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when barring info is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsBarringResponse> SsSetBarring(SsBarringInfo info)
+        {
+            TaskCompletionSource<SsBarringResponse> task = new TaskCompletionSource<SsBarringResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during setting SS barring info: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs during setting SS barring info, " + (SsCause)result));
+                    }
+
+                    SsBarringResponseStruct response = Marshal.PtrToStructure<SsBarringResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertBarringRspStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            if (info == null)
+            {
+                throw new ArgumentNullException("Ss barring info is null");
+            }
+
+            SsBarringInfoStruct infoStruct = SsClassConversions.ConvertSsBarringInfo(info);
+            int ret = Interop.Tapi.Ss.SsSetBarring(_handle, ref infoStruct, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to set barring info, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Gets call barring status.
+        /// </summary>
+        /// <param name="ssClass">The type of call.</param>
+        /// <param name="type">The barring type.</param>
+        /// <returns>A task containing information about barring response.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsBarringResponse> SsGetBarringStatus(SsClass ssClass, SsBarringType type)
+        {
+            TaskCompletionSource<SsBarringResponse> task = new TaskCompletionSource<SsBarringResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in getting barring status: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in getting barring status, " + (SsCause)result));
+                    }
+
+                    SsBarringResponseStruct response = Marshal.PtrToStructure<SsBarringResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertBarringRspStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Ss.SsGetBarringStatus(_handle, ssClass, type, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get barring status, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Allows changing of the barring password in the network.
+        /// </summary>
+        /// <param name="oldPassword">The old password set for Barring in the Network.</param>
+        /// <param name="newPassword">The new password set for Barring in the Network.</param>
+        /// <param name="newPasswordAgain">The new password again.</param>
+        /// <returns>A task indicating whether the change of password is done or not.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privlevel>platform</privlevel>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when any of the parameter is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task SsChangeBarringPassword(string oldPassword, string newPassword, string newPasswordAgain)
+        {
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in changing barring password: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in changing barring password, " + (SsCause)result));
+                    }
+
+                    task.SetResult(true);
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            if (oldPassword == null || newPassword == null || newPasswordAgain == null)
+            {
+                throw new ArgumentNullException("Old password/new password is null");
+            }
+
+            int ret = Interop.Tapi.Ss.SsChangeBarringPassword(_handle, oldPassword, newPassword, newPasswordAgain, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to change barring password, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Allows to set the (register/erase/activate/deactivate) call forwarding option at the network.
+        /// </summary>
+        /// <param name="info">The Call forward information such as a forward mode, a forward type, and so on.</param>
+        /// <returns>A task containing information about SS forward response.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privlevel>platform</privlevel>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when forward info is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsForwardResponse> SsSetForwardInfo(SsForwardInfo info)
+        {
+            TaskCompletionSource<SsForwardResponse> task = new TaskCompletionSource<SsForwardResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in setting SS forward info: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in setting SS forward info, " + (SsCause)result));
+                    }
+
+                    SsForwardResponseStruct response = Marshal.PtrToStructure<SsForwardResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertForwardRspStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            if (info == null)
+            {
+                throw new ArgumentNullException("Ss forward info is null");
+            }
+
+            SsForwardInfoStruct infoStruct = SsClassConversions.ConvertSsForwardInfo(info);
+            int ret = Interop.Tapi.Ss.SsSetForward(_handle, ref infoStruct, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to set forward info, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Provides an option to get the call forwarding status of different calls from the Network.
+        /// </summary>
+        /// <param name="ssClass">The Forward call type.</param>
+        /// <param name="condition">The forward condition.</param>
+        /// <returns>A task containing SS forward response information.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsForwardResponse> SsGetForwardStatus(SsClass ssClass, SsForwardCondition condition)
+        {
+            TaskCompletionSource<SsForwardResponse> task = new TaskCompletionSource<SsForwardResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in getting SS forward status: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in getting SS forward status, " + (SsCause)result));
+                    }
+
+                    SsForwardResponseStruct response = Marshal.PtrToStructure<SsForwardResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertForwardRspStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Ss.SsGetForwardStatus(_handle, ssClass, condition, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get forward status, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Activates/deactivates the call waiting service.
+        /// </summary>
+        /// <param name="info">The status of call-waiting service.</param>
+        /// <returns>A task containing SS waiting response information.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privlevel>platform</privlevel>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when waiting info is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsWaitingResponse> SsSetWaitingInfo(SsWaitingInfo info)
+        {
+            TaskCompletionSource<SsWaitingResponse> task = new TaskCompletionSource<SsWaitingResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in setting SS waiting info: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in setting SS waiting info, " + (SsCause)result));
+                    }
+
+                    SsWaitingResponseStruct response = Marshal.PtrToStructure<SsWaitingResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertWaitingRspStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            if (info == null)
+            {
+                throw new ArgumentNullException("Ss waiting info is null");
+            }
+
+            SsWaitingInfoStruct infoStruct = SsClassConversions.ConvertSsWaitingInfo(info);
+            int ret = Interop.Tapi.Ss.SsSetWaiting(_handle, ref infoStruct, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to set waiting info, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Gets the status of the call waiting service.
+        /// </summary>
+        /// <param name="ssClass">The call types.</param>
+        /// <returns>A task containing information about SS waiting response.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsWaitingResponse> SsGetWaitingInfo(SsClass ssClass)
+        {
+            TaskCompletionSource<SsWaitingResponse> task = new TaskCompletionSource<SsWaitingResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in getting SS waiting info: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in getting SS waiting info, " + (SsCause)result));
+                    }
+
+                    SsWaitingResponseStruct response = Marshal.PtrToStructure<SsWaitingResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertWaitingRspStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Ss.SsGetWaitingStatus(_handle, ssClass, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get waiting info, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Activates/deactivates the status of the calling line identity service.
+        /// </summary>
+        /// <param name="type">The Cli service type.</param>
+        /// <param name="status">The Cli Status.</param>
+        /// <returns>A task indicating whether setting of CLI status is done or not.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privlevel>platform</privlevel>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<bool> SsSetCliStatus(SsCliType type, SsCliStatus status)
+        {
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in setting SS CLI status: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in setting SS CLI status, " + (SsCause)result));
+                    }
+
+                    task.SetResult(true);
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Ss.SsSetCliStatus(_handle, type, status, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to set SS CLI status, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Gets the status of the calling line identity service.
+        /// </summary>
+        /// <param name="type">The Cli service type.</param>
+        /// <returns>A task containing SS CLI response information.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsCliResponse> SsGetCliStatus(SsCliType type)
+        {
+            TaskCompletionSource<SsCliResponse> task = new TaskCompletionSource<SsCliResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in getting SS CLI status: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in getting SS CLI status, " + (SsCause)result));
+                    }
+
+                    SsCliResponseStruct response = Marshal.PtrToStructure<SsCliResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertSsCliResponseStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Ss.SsGetCliStatus(_handle, type, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get CLI status, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Sends a USSD string or User response to the Network.
+        /// </summary>
+        /// <param name="info">The data coding scheme used</param>
+        /// <returns>A task containing SS USSD response information.</returns>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <privlevel>platform</privlevel>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when Ussd message info is passed as null.</exception>
+        /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception>
+        public Task<SsUssdResponse> SsSendUssdRequest(SsUssdMsgInfo info)
+        {
+            TaskCompletionSource<SsUssdResponse> task = new TaskCompletionSource<SsUssdResponse>();
+            IntPtr id = (IntPtr)_requestId++;
+            _callbackMap[id] = (handle, result, data, key) =>
+            {
+                Task taskResult = new Task(() =>
+                {
+                    if (result != (int)SsCause.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs in sending USSD request: " + (SsCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs in sending USSD request, " + (SsCause)result));
+                    }
+
+                    SsUssdResponseStruct response = Marshal.PtrToStructure<SsUssdResponseStruct>(data);
+                    task.SetResult(SsStructConversions.ConvertSsUssdResponseStruct(response));
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            if (info == null)
+            {
+                throw new ArgumentNullException("Ussd message info is null");
+            }
+
+            SsUssdMsgInfoStruct msgStruct = SsClassConversions.ConvertSsUssdMsgInfo(info);
+            int ret = Interop.Tapi.Ss.SsSendUssdRequest(_handle, ref msgStruct, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to send USSD request, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+    }
+}
index 926c965..9901405 100755 (executable)
  * limitations under the License.
  */
 
-using System.Text;
 using System.Collections.Generic;
 
 namespace Tizen.Tapi
 {
     /// <summary>
-    /// A class which defines values for USSD request type. Applicable to 3GPP(GSM?UMTS/LET) only.
+    /// A class which defines values for USSD request type. Applicable to 3GPP(GSM/UMTS/LET) only.
     /// </summary>
     public class SsUssdMsgInfo
     {
-        internal SsUssdType SsType;
-        internal byte SsDcs;
-        internal int SsLength;
-        internal string Ussd;
-
-        internal SsUssdMsgInfo()
-        {
-        }
+        private SsUssdType _type;
+        private byte _dcs;
+        private int _length;
+        private string _ussdString;
 
         /// <summary>
         /// USSD type.
@@ -41,7 +36,12 @@ namespace Tizen.Tapi
         {
             get
             {
-                return SsType;
+                return _type;
+            }
+
+            set
+            {
+                _type = value;
             }
         }
 
@@ -53,7 +53,12 @@ namespace Tizen.Tapi
         {
             get
             {
-                return SsDcs;
+                return _dcs;
+            }
+
+            set
+            {
+                _dcs = value;
             }
         }
 
@@ -65,7 +70,12 @@ namespace Tizen.Tapi
         {
             get
             {
-                return SsLength;
+                return _length;
+            }
+
+            set
+            {
+                _length = value;
             }
         }
 
@@ -77,7 +87,12 @@ namespace Tizen.Tapi
         {
             get
             {
-                return Ussd;
+                return _ussdString;
+            }
+
+            set
+            {
+                _ussdString = value;
             }
         }
     }
@@ -468,4 +483,302 @@ namespace Tizen.Tapi
             }
         }
     }
+
+    /// <summary>
+    /// A class which defines parameters related to call barring.
+    /// </summary>
+    public class SsBarringInfo
+    {
+        private SsClass _class;
+        private SsBarringMode _mode;
+        private SsBarringType _type;
+        private string _password;
+        private SsBarringInfo()
+        {
+        }
+
+        /// <summary>
+        /// A constructor for instantiating SsBarringInfo class with the necessary parameters.
+        /// </summary>
+        /// <param name="classType">Call type.</param>
+        /// <param name="mode">Barring mode.</param>
+        /// <param name="type">Barring type.</param>
+        /// <param name="password">Password (3GPP(GSM/UMTS/LTE) Specific).</param>
+        public SsBarringInfo(SsClass classType, SsBarringMode mode, SsBarringType type, string password)
+        {
+            _class = classType;
+            _mode = mode;
+            _type = type;
+            _password = password;
+        }
+
+        internal SsClass Class
+        {
+            get
+            {
+                return _class;
+            }
+        }
+
+        internal SsBarringMode Mode
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+
+        internal SsBarringType Type
+        {
+            get
+            {
+                return _type;
+            }
+        }
+
+        internal string Password
+        {
+            get
+            {
+                return _password;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which defines the parameters related to forward info.
+    /// </summary>
+    public class SsForwardInfo
+    {
+        private SsClass _class;
+        private SsForwardMode _mode;
+        private SsForwardCondition _condition;
+        private SsNoReplyTime _noReplyTimer;
+        private SsForwardTypeOfNumber _ton;
+        private SsForwardNumberingPlanIdentity _npi;
+        private string _phoneNumber;
+        private SsForwardInfo()
+        {
+        }
+
+        /// <summary>
+        /// A constructor for instantiating SsForwardInfo class with the necessary parameters.
+        /// </summary>
+        /// <param name="classType">SS Class.</param>
+        /// <param name="mode">Forward Mode.</param>
+        /// <param name="condition">Forward Condition.</param>
+        /// <param name="time">No reply wait time 5-30 secs in intervals of 5(3GPP(GSM/UMTS/LTE) Specific).</param>
+        /// <param name="ton">Type of number.</param>
+        /// <param name="npi">Numbering plan identity.</param>
+        /// <param name="number">Phone number.</param>
+        public SsForwardInfo(SsClass classType, SsForwardMode mode, SsForwardCondition condition, SsNoReplyTime time, SsForwardTypeOfNumber ton, SsForwardNumberingPlanIdentity npi, string number)
+        {
+            _class = classType;
+            _mode = mode;
+            _condition = condition;
+            _noReplyTimer = time;
+            _ton = ton;
+            _npi = npi;
+            _phoneNumber = number;
+        }
+
+        internal SsClass Class
+        {
+            get
+            {
+                return _class;
+            }
+        }
+
+        internal SsForwardMode Mode
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+
+        internal SsForwardCondition Condition
+        {
+            get
+            {
+                return _condition;
+            }
+        }
+
+        internal SsNoReplyTime NoReplyTimer
+        {
+            get
+            {
+                return _noReplyTimer;
+            }
+        }
+
+        internal SsForwardTypeOfNumber Ton
+        {
+            get
+            {
+                return _ton;
+            }
+        }
+
+        internal SsForwardNumberingPlanIdentity Npi
+        {
+            get
+            {
+                return _npi;
+            }
+        }
+
+        internal string PhoneNumber
+        {
+            get
+            {
+                return _phoneNumber;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which defines parameters related to call waiting.
+    /// </summary>
+    public class SsWaitingInfo
+    {
+        private SsClass _class;
+        private SsCallWaitingMode _mode;
+        private SsWaitingInfo()
+        {
+        }
+
+        /// <summary>
+        /// A constructor for instantiating SsWaitingInfo class with necessary parameters.
+        /// </summary>
+        /// <param name="ssClass">Call type.</param>
+        /// <param name="mode">Call waiting mode.</param>
+        public SsWaitingInfo(SsClass ssClass, SsCallWaitingMode mode)
+        {
+            _class = ssClass;
+            _mode = mode;
+        }
+
+        internal SsClass Class
+        {
+            get
+            {
+                return _class;
+            }
+        }
+
+        internal SsCallWaitingMode Mode
+        {
+            get
+            {
+                return _mode;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which defines values for calling line identity service. Applicable to 3GPP(GSM/UMTS/LTE) only.
+    /// </summary>
+    public class SsCliResponse
+    {
+        internal SsLineIdentificationType LineType;
+        internal SsCliStatus CliStatus;
+        internal SsCliResponse()
+        {
+        }
+
+        /// <summary>
+        /// Various line identification types.
+        /// </summary>
+        public SsLineIdentificationType Type
+        {
+            get
+            {
+                return LineType;
+            }
+        }
+
+        /// <summary>
+        /// Line identification status from the network.
+        /// </summary>
+        public SsCliStatus Status
+        {
+            get
+            {
+                return CliStatus;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which defines USSD response data. Applicable to 3GPP(GSM/UMTS/LTE) only.
+    /// </summary>
+    public class SsUssdResponse
+    {
+        internal SsUssdType UssdType;
+        internal SsUssdStatus UssdStatus;
+        internal byte DcsInfo;
+        internal int UssdLength;
+        internal string UssdInfo;
+        internal SsUssdResponse()
+        {
+        }
+
+        /// <summary>
+        /// USSD Type.
+        /// </summary>
+        public SsUssdType Type
+        {
+            get
+            {
+                return UssdType;
+            }
+        }
+
+        /// <summary>
+        /// USSD Status.
+        /// </summary>
+        public SsUssdStatus Status
+        {
+            get
+            {
+                return UssdStatus;
+            }
+        }
+
+        /// <summary>
+        /// DCS.
+        /// </summary>
+        public byte Dcs
+        {
+            get
+            {
+                return DcsInfo;
+            }
+        }
+
+        /// <summary>
+        /// USSD string length.
+        /// </summary>
+        public int Length
+        {
+            get
+            {
+                return UssdLength;
+            }
+        }
+
+        /// <summary>
+        /// USSD String.
+        /// </summary>
+        public string UssdString
+        {
+            get
+            {
+                return UssdInfo;
+            }
+        }
+    }
 }
index 5d79bea..9d9e4ac 100755 (executable)
@@ -714,4 +714,123 @@ namespace Tizen.Tapi
         /// </summary>
         Max
     }
+
+    /// <summary>
+    /// Enumeration for the call barring operation mode.
+    /// </summary>
+    public enum SsBarringMode
+    {
+        /// <summary>
+        /// Activate call barring.
+        /// </summary>
+        Activate,
+        /// <summary>
+        /// Deactivate call barring.
+        /// </summary>
+        Deactivate
+    }
+
+    /// <summary>
+    /// Enumeration for the forward mode.
+    /// </summary>
+    public enum SsForwardMode
+    {
+        /// <summary>
+        /// Deactivate call forwarding.
+        /// </summary>
+        Disable,
+        /// <summary>
+        /// Activate call forwarding.
+        /// </summary>
+        Enable,
+        /// <summary>
+        /// Register call forwarding.
+        /// </summary>
+        Registration,
+        /// <summary>
+        /// Deregister call forwarding.
+        /// </summary>
+        Erasure
+    }
+
+    /// <summary>
+    /// Enumeration for the call waiting mode.
+    /// </summary>
+    public enum SsCallWaitingMode
+    {
+        /// <summary>
+        /// Activate call waiting.
+        /// </summary>
+        Activate,
+        /// <summary>
+        /// Deactivate call waiting.
+        /// </summary>
+        Deactivate
+    }
+
+    /// <summary>
+    /// Enumeration for the types of identity presentation / restriction services.
+    /// </summary>
+    public enum SsLineIdentificationType
+    {
+        /// <summary>
+        /// Identify the party calling this phone.
+        /// </summary>
+        CallingLinePresentation = 0x01,
+        /// <summary>
+        /// Hide the identity of this phone when calling others.
+        /// </summary>
+        CallingLineRestriction,
+        /// <summary>
+        /// Identify the party to whom the calling party (this phone) is connected. 3GPP(GSM/UMTS/LTE) Specific.
+        /// </summary>
+        ConnectedLinePresentation,
+        /// <summary>
+        /// Restrict yourself from being identified by incoming calls, such as forwarded calls. 3GPP(GSM/UMTS/LTE) Specific.
+        /// </summary>
+        ConnectedLineRestriction,
+        /// <summary>
+        /// Called line identity presentation. 3GPP(GSM/UMTS/LTE) Specific.
+        /// </summary>
+        CalledLinePresentation,
+        /// <summary>
+        /// Calling Name Presentation. 3GPP(GSM/UMTS/LTE) Specific.
+        /// </summary>
+        CallingNamePresentation
+    }
+
+    /// <summary>
+    /// Enumeration for the USSD indication type. Applicable to 3GPP(GSM/UMTS/LTE) only.
+    /// </summary>
+    public enum SsUssdStatus
+    {
+        /// <summary>
+        /// Notify : to display USSD data to the user.
+        /// </summary>
+        Notify = 0x00,
+        /// <summary>
+        /// No further user action required.
+        /// </summary>
+        NoActionRequire = 0x01,
+        /// <summary>
+        /// Further user action required.
+        /// </summary>
+        ActionRequire = 0x02,
+        /// <summary>
+        /// USSD terminated by the network.
+        /// </summary>
+        TerminatedByNetwork = 0x03,
+        /// <summary>
+        /// Other local client has responded.
+        /// </summary>
+        OtherClient = 0x04,
+        /// <summary>
+        /// Operation not supported.
+        /// </summary>
+        NotSupport = 0x05,
+        /// <summary>
+        /// Time out when there is no response from the network.
+        /// </summary>
+        TimeOut = 0x06
+    }
 }
index c4d48f7..302a6b5 100755 (executable)
@@ -23,6 +23,11 @@ namespace Tizen.Tapi
     [StructLayout(LayoutKind.Sequential)]
     internal struct SsBarringInfoStruct
     {
+        internal SsClass Class;
+        internal SsBarringMode Mode;
+        internal SsBarringType Type;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
+        internal string Password;
     }
 
     [StructLayout(LayoutKind.Sequential)]
@@ -52,6 +57,17 @@ namespace Tizen.Tapi
     }
 
     [StructLayout(LayoutKind.Sequential)]
+    internal struct SsUssdResponseStruct
+    {
+        internal SsUssdType Type;
+        internal SsUssdStatus Status;
+        internal byte Dcs;
+        internal int Length;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 208)]
+        internal string UssdString;
+    }
+
+    [StructLayout(LayoutKind.Sequential)]
     internal struct SsReleaseCompleteMsgStruct
     {
         internal byte MsgLength;
@@ -62,6 +78,8 @@ namespace Tizen.Tapi
     [StructLayout(LayoutKind.Sequential)]
     internal struct SsWaitingInfoStruct
     {
+        internal SsClass Class;
+        internal SsCallWaitingMode Mode;
     }
 
     [StructLayout(LayoutKind.Sequential)]
@@ -82,6 +100,14 @@ namespace Tizen.Tapi
     [StructLayout(LayoutKind.Sequential)]
     internal struct SsForwardInfoStruct
     {
+        internal SsClass Class;
+        internal SsForwardMode Mode;
+        internal SsForwardCondition Condition;
+        internal SsNoReplyTime NoReplyTimer;
+        internal SsForwardTypeOfNumber Ton;
+        internal SsForwardNumberingPlanIdentity Npi;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 82)]
+        internal string PhoneNumber;
     }
 
     [StructLayout(LayoutKind.Sequential)]
@@ -113,6 +139,13 @@ namespace Tizen.Tapi
         internal SsInfoType Type;
     }
 
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct SsCliResponseStruct
+    {
+        internal SsLineIdentificationType Type;
+        internal SsCliStatus Status;
+    }
+
     internal static class SsStructConversions
     {
         internal static SsForwardRecord ConvertSsForwardRecordStruct(SsForwardRecordStruct recordStruct)
@@ -141,10 +174,10 @@ namespace Tizen.Tapi
         internal static SsUssdMsgInfo ConvertSsMsgStruct(SsUssdMsgInfoStruct msgStruct)
         {
             SsUssdMsgInfo info = new SsUssdMsgInfo();
-            info.SsLength = msgStruct.Length;
-            info.SsDcs = msgStruct.Dcs;
-            info.Ussd = msgStruct.UssdString;
-            info.SsType = msgStruct.Type;
+            info.Length = msgStruct.Length;
+            info.Dcs = msgStruct.Dcs;
+            info.UssdString = msgStruct.UssdString;
+            info.Type = msgStruct.Type;
             return info;
         }
 
@@ -212,5 +245,68 @@ namespace Tizen.Tapi
             info.Type = infoStruct.Type;
             return info;
         }
+
+        internal static SsCliResponse ConvertSsCliResponseStruct(SsCliResponseStruct responseStruct)
+        {
+            SsCliResponse response = new SsCliResponse();
+            response.LineType = responseStruct.Type;
+            response.CliStatus = responseStruct.Status;
+            return response;
+        }
+
+        internal static SsUssdResponse ConvertSsUssdResponseStruct(SsUssdResponseStruct responseStruct)
+        {
+            SsUssdResponse response = new SsUssdResponse();
+            response.UssdType = responseStruct.Type;
+            response.UssdStatus = responseStruct.Status;
+            response.DcsInfo = responseStruct.Dcs;
+            response.UssdLength = responseStruct.Length;
+            response.UssdInfo = responseStruct.UssdString;
+            return response;
+        }
+    }
+
+    internal static class SsClassConversions
+    {
+        internal static SsBarringInfoStruct ConvertSsBarringInfo(SsBarringInfo info)
+        {
+            SsBarringInfoStruct barringStruct = new SsBarringInfoStruct();
+            barringStruct.Class = info.Class;
+            barringStruct.Mode = info.Mode;
+            barringStruct.Type = info.Type;
+            barringStruct.Password = info.Password;
+            return barringStruct;
+        }
+
+        internal static SsForwardInfoStruct ConvertSsForwardInfo(SsForwardInfo info)
+        {
+            SsForwardInfoStruct forwardStruct = new SsForwardInfoStruct();
+            forwardStruct.Class = info.Class;
+            forwardStruct.Mode = info.Mode;
+            forwardStruct.Condition = info.Condition;
+            forwardStruct.NoReplyTimer = info.NoReplyTimer;
+            forwardStruct.Ton = info.Ton;
+            forwardStruct.Npi = info.Npi;
+            forwardStruct.PhoneNumber = info.PhoneNumber;
+            return forwardStruct;
+        }
+
+        internal static SsWaitingInfoStruct ConvertSsWaitingInfo(SsWaitingInfo info)
+        {
+            SsWaitingInfoStruct waitingStruct = new SsWaitingInfoStruct();
+            waitingStruct.Class = info.Class;
+            waitingStruct.Mode = info.Mode;
+            return waitingStruct;
+        }
+
+        internal static SsUssdMsgInfoStruct ConvertSsUssdMsgInfo(SsUssdMsgInfo info)
+        {
+            SsUssdMsgInfoStruct msgStruct = new SsUssdMsgInfoStruct();
+            msgStruct.Type = info.Type;
+            msgStruct.Dcs = info.Dcs;
+            msgStruct.Length = info.Length;
+            msgStruct.UssdString = info.UssdString;
+            return msgStruct;
+        }
     }
 }