Merge "[Tapi] Implementation of Phonebook APIs" into tizen
authorShinhui Kang <sinikang@samsung.com>
Fri, 16 Jun 2017 07:47:48 +0000 (07:47 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 16 Jun 2017 07:47:48 +0000 (07:47 +0000)
src/Tizen.Tapi/Interop/Interop.Tapi.cs
src/Tizen.Tapi/Tizen.Tapi/Call.cs
src/Tizen.Tapi/Tizen.Tapi/Modem.cs [new file with mode: 0755]
src/Tizen.Tapi/Tizen.Tapi/ModemData.cs [new file with mode: 0755]
src/Tizen.Tapi/Tizen.Tapi/ModemEnumerations.cs
src/Tizen.Tapi/Tizen.Tapi/ModemStructs.cs
src/Tizen.Tapi/Tizen.Tapi/NetworkEnumerations.cs
src/Tizen.Tapi/Tizen.Tapi/Oem.cs [new file with mode: 0755]

index d2dbaeb..ab65fa8 100755 (executable)
@@ -267,7 +267,7 @@ internal static partial class Interop
         internal static class Modem
         {
             [DllImport(Libraries.Tapi, EntryPoint = "tel_process_power_command")]
-            internal static extern int ProcessPowerCommand(IntPtr handle, PhonePowerCommand cmd, IntPtr data, uint length);
+            internal static extern int ProcessPowerCommand(IntPtr handle, PhonePowerCommand cmd, TapiResponseCallback cb, IntPtr userData);
             [DllImport(Libraries.Tapi, EntryPoint = "tel_set_flight_mode")]
             internal static extern int SetFlightMode(IntPtr handle, PowerFlightModeRequest mode, TapiResponseCallback cb, IntPtr userData);
             [DllImport(Libraries.Tapi, EntryPoint = "tel_get_flight_mode")]
index 047f75a..c991410 100755 (executable)
@@ -39,7 +39,7 @@ namespace Tizen.Tapi
         {
             if (handle == null)
             {
-                throw new ArgumentNullException();
+                throw new ArgumentNullException("TapiHandle parameter is null");
             }
 
             _handle = handle._handle;
@@ -51,6 +51,7 @@ namespace Tizen.Tapi
         /// <param name="info">Information of call type and number.</param>
         /// <returns>A task indicating whether the DialCall method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// Register the telephony event with proper Notification enum value which is to be listened using RegisterNotiEvent.
@@ -108,6 +109,7 @@ namespace Tizen.Tapi
         /// <param name="type">The answer type.</param>
         /// <returns>The call id of answer call. This call handle is available to the application through an incoming call(IncomingVoiceCall) event.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// There can be a maximum of one existing call.
@@ -157,6 +159,7 @@ namespace Tizen.Tapi
         /// <param name="type">The end call type.</param>
         /// <returns>Instance of CallEndData.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// There should be an existing call in the active/hold state.
@@ -206,6 +209,7 @@ namespace Tizen.Tapi
         /// <param name="callHandle">Unique handle for referring the call.</param>
         /// <returns>The call id of hold call.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// The call should be in the active state.
@@ -254,6 +258,7 @@ namespace Tizen.Tapi
         /// <param name="callHandle">Unique handle for referring the call.</param>
         /// <returns>The call id of active call.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// Call should be in the held state in order to retrieve it into the active state unless no active call is present.
@@ -303,6 +308,7 @@ namespace Tizen.Tapi
         /// <param name="heldCallHandle">Held call.</param>
         /// <returns>The call id of swap call.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// Register the telephony event with proper Notification enum value which is to be listened using RegisterNotiEvent.
@@ -350,6 +356,7 @@ namespace Tizen.Tapi
         /// <param name="digit">The dtmf digit to be sent.</param>
         /// <returns>A task indicating whether the StartContDtmfCall method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks> An active call should be present. This is to be invoked in the following cases:
         /// i. Key Release (post key press) during on-going call.
@@ -397,6 +404,7 @@ namespace Tizen.Tapi
         /// </summary>
         /// <returns>A task indicating whether the StopContDtmfCall method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks> An active call should be present. This is to be invoked in the following cases:
         /// i. Key Release (post key press) during on-going call.
@@ -445,6 +453,7 @@ namespace Tizen.Tapi
         /// <param name="dtmfData">A burst dtmf info containing dtmf string, pulse width, and inter digit interval.</param>
         /// <returns>A task indicating whether the SendBurstDtmfCall method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// There will be a single asynchronous notification for all the dtmf digits sent. If the users of this API need an asynchronous
@@ -503,6 +512,7 @@ namespace Tizen.Tapi
         /// <param name="callHandle">Unique call handle.</param>
         /// <returns>The call id of join call.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// For a multiparty call or for joining two calls into conference, there should be one call in the active state and another call in the held state.
@@ -551,6 +561,7 @@ namespace Tizen.Tapi
         /// <param name="callHandle">The handle of the call to be made private. The call handle referring to the call that is to be split from the conference.</param>
         /// <returns>The call id of split call.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// The call should be in a multiparty conference call.The split call will be the active call and the conference call will be the held call.
@@ -599,6 +610,7 @@ namespace Tizen.Tapi
         /// <param name="activeCallHandle">The call handle of an active call.</param>
         /// <returns>The call id of transferred call.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>
         /// In order to transfer call, served mobile subscriber should have 2 calls, one in the active state and another one in the held state.
@@ -648,6 +660,7 @@ namespace Tizen.Tapi
         /// <param name="destinationNumber">The destination number.</param>
         /// <returns>A task indicating whether the DeflectCall method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>Register the telephony event with proper Notification enum value which is to be listened using RegisterNotiEvent.</remarks>
         /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
@@ -795,6 +808,7 @@ namespace Tizen.Tapi
         /// <param name="record">The call volume information.</param>
         /// <returns>A task indicating whether the SetCallVolumeInfo method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
         /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
@@ -848,6 +862,7 @@ namespace Tizen.Tapi
         /// <param name="path">The call sound path information.</param>
         /// <returns>A task indicating whether the SetCallSoundPath method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
         /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
@@ -901,6 +916,7 @@ namespace Tizen.Tapi
         /// <param name="record">The call mute status information.</param>
         /// <returns>A task indicating whether the SetCallMuteStatus method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
         /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
@@ -1042,6 +1058,7 @@ namespace Tizen.Tapi
         /// <param name="mode">Voice privacy option mode value.</param>
         /// <returns>A task indicating whether the SetCallPrivacyMode method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <remarks>Register the telephony event with proper Notification enum value which is to be listened using RegisterNotiEvent.</remarks>
         /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
@@ -1086,6 +1103,7 @@ namespace Tizen.Tapi
         /// <param name="subscription">Preferred voice subscription value.</param>
         /// <returns>A task indicating whether the SetCallPreferredVoiceSubscription method is done or not.</returns>
         /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
         /// <feature>http://tizen.org/feature/network.telephony</feature>
         /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
         /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
diff --git a/src/Tizen.Tapi/Tizen.Tapi/Modem.cs b/src/Tizen.Tapi/Tizen.Tapi/Modem.cs
new file mode 100755 (executable)
index 0000000..074bfc1
--- /dev/null
@@ -0,0 +1,433 @@
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Tapi
+{
+    /// <summary>
+    /// This class provides functions for modem services.
+    /// </summary>
+    public class Modem
+    {
+        private IntPtr _handle;
+        private Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback> _response_map = new Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback>();
+        private int _requestId = 0;
+
+        /// <summary>
+        /// A public constructor for Modem class to create a Modem instance for the given tapi handle.
+        /// </summary>
+        /// <param name="handle">The tapi handle.</param>
+        public Modem(TapiHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException("TapiHandle parameter is null");
+            }
+
+            _handle = handle._handle;
+        }
+
+        /// <summary>
+        /// Turn the modem on/off asynchronously.
+        /// </summary>
+        /// <param name="cmd">Power command value.</param>
+        /// <returns>A task indicating whether the ProcessPowerCommand method is done or not.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task ProcessPowerCommand(PhonePowerCommand cmd)
+        {
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)TapiError.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during turning modem on/off, " + (TapiError)result);
+                        task.SetException(new InvalidOperationException("Error occurs during turning modem on/off, " + (TapiError)result));
+                    }
+
+                    task.SetResult(true);
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.ProcessPowerCommand(_handle, cmd, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to turn the modem on/off, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Switch the flight mode on/off asynchronously.
+        /// </summary>
+        /// <param name="mode">Flight mode request value.</param>
+        /// <returns>A task indicating whether the SetFlightMode method is done or not.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task SetFlightMode(PowerFlightModeRequest mode)
+        {
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if ((mode == PowerFlightModeRequest.Leave && result != (int)PowerFlightModeResponse.On) ||
+                        (mode == PowerFlightModeRequest.Enter && result != (int)PowerFlightModeResponse.Off))
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during switching flight mode on/off, " + (PowerFlightModeResponse)result);
+                        task.SetException(new InvalidOperationException("Error occurs during switching flight mode on/off, " + (PowerFlightModeResponse)result));
+                    }
+
+                    task.SetResult(true);
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.SetFlightMode(_handle, mode, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to switch the flight mode on/off, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Get the flight mode asynchronously.
+        /// </summary>
+        /// <returns>If flight mode is On, it returns true else it returns false.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task<bool> GetFlightMode()
+        {
+            TaskCompletionSource<bool> task = new TaskCompletionSource<bool>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)TapiError.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the flight mode, " + (TapiError)result);
+                        task.SetException(new InvalidOperationException("Error occurs during getting the flight mode, " + (TapiError)result));
+                    }
+
+                    int mode = Marshal.ReadInt32(data);
+                    if (mode == 1)
+                    {
+                        task.SetResult(true);
+                    }
+
+                    else
+                    {
+                        task.SetResult(false);
+                    }
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.GetFlightMode(_handle, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get the flight mode, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Get Me version information asynchronously.
+        /// </summary>
+        /// <returns>Instance of MiscVersionInformation.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task<MiscVersionInformation> GetMiscMeVersion()
+        {
+            TaskCompletionSource<MiscVersionInformation> task = new TaskCompletionSource<MiscVersionInformation>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)TapiError.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Me version, " + (TapiError)result);
+                        task.SetException(new InvalidOperationException("Error occurs during getting the Me version, " + (TapiError)result));
+                    }
+
+                    MiscVersionInfoStruct infoStruct = Marshal.PtrToStructure<MiscVersionInfoStruct>(data);
+                    MiscVersionInformation versionInfoClass = ModemStructConversions.ConvertVersionStruct(infoStruct);
+                    task.SetResult(versionInfoClass);
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.GetFlightMode(_handle, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get the Me version information, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Misc me version information.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <remarks>Returns null in case of failure.</remarks>
+        public MiscVersionInformation MiscMeVersionSync
+        {
+            get
+            {
+                MiscVersionInfoStruct infoStruct = Interop.Tapi.Modem.GetMiscMeVersionSync(_handle);
+                if (infoStruct.Equals(null))
+                {
+                    return null;
+                }
+
+                MiscVersionInformation versionInfoClass = ModemStructConversions.ConvertVersionStruct(infoStruct);
+                return versionInfoClass;
+            }
+        }
+
+        /// <summary>
+        /// Get the Me Esn/Meid for each phone type asynchronously.
+        /// </summary>
+        /// <returns>Instance of MiscSerialNumberInformation.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task<MiscSerialNumberInformation> GetMiscMeSn()
+        {
+            TaskCompletionSource<MiscSerialNumberInformation> task = new TaskCompletionSource<MiscSerialNumberInformation>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)TapiError.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Me Esn/Meid, " + (TapiError)result);
+                        task.SetException(new InvalidOperationException("Error occurs during getting the Me Esn/Meid, " + (TapiError)result));
+                    }
+
+                    MiscSerialNumInfoStruct infoStruct = Marshal.PtrToStructure<MiscSerialNumInfoStruct>(data);
+                    MiscSerialNumberInformation serialNumberClass = ModemStructConversions.ConvertSerialNumberStruct(infoStruct);
+                    task.SetResult(serialNumberClass);
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.GetMiscMeSn(_handle, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get the Me Esn/Meid information for each phone type, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Misc me serial number information.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <remarks>Returns null in case of failure.</remarks>
+        public MiscSerialNumberInformation MiscMeSnSync
+        {
+            get
+            {
+                MiscSerialNumInfoStruct infoStruct = Interop.Tapi.Modem.GetMiscMeSnSync(_handle);
+                if (infoStruct.Equals(null))
+                {
+                    return null;
+                }
+
+                MiscSerialNumberInformation versionInfoClass = ModemStructConversions.ConvertSerialNumberStruct(infoStruct);
+                return versionInfoClass;
+            }
+        }
+
+        /// <summary>
+        /// Get the Misc Me Imei asynchronously.
+        /// </summary>
+        /// <returns>The imei string.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task<string> GetMiscMeImei()
+        {
+            TaskCompletionSource<string> task = new TaskCompletionSource<string>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)TapiError.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the Misc Me Imei, " + (TapiError)result);
+                        task.SetException(new InvalidOperationException("Error occurs during getting the Misc Me Imei, " + (TapiError)result));
+                    }
+
+                    task.SetResult(Marshal.PtrToStringAnsi(data));
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.GetMiscMeImei(_handle, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get the Misc Me Imei information, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Misc me Imei information.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <remarks>Returns null in case of failure.</remarks>
+        public string MiscMeImeiSync
+        {
+            get
+            {
+                string imei = Interop.Tapi.Modem.GetMiscMeImeiSync(_handle);
+                if (imei == null)
+                {
+                    return null;
+                }
+
+                return imei;
+            }
+        }
+
+        /// <summary>
+        /// Check the modem power status.
+        /// </summary>
+        /// <returns>Phone power status value.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public PhonePowerStatus CheckPowerStatus()
+        {
+            int result;
+            int ret = Interop.Tapi.Modem.CheckPowerStatus(_handle, out result);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to check the modem power status, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return (PhonePowerStatus)result;
+        }
+
+        /// <summary>
+        /// Get device vendor name and device name of cellular dongle.
+        /// </summary>
+        /// <returns>Instance of MiscDeviceInfo.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony</privilege>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <remarks>
+        /// Result can be delivered with only cellular dongle insertion.
+        /// </remarks>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when modem instance is invalid or when method failed due to invalid operation.</exception>
+        public Task<MiscDeviceInfo> GetDeviceInfo()
+        {
+            TaskCompletionSource<MiscDeviceInfo> task = new TaskCompletionSource<MiscDeviceInfo>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr data, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)TapiError.Success)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during getting the device name and vendor name, " + (TapiError)result);
+                        task.SetException(new InvalidOperationException("Error occurs during getting the device name and vendor name, " + (TapiError)result));
+                    }
+
+                    MiscDeviceInfoStruct infoStruct = Marshal.PtrToStructure<MiscDeviceInfoStruct>(data);
+                    MiscDeviceInfo deviceInfo = ModemStructConversions.ConvertMiscInfoStruct(infoStruct);
+                    task.SetResult(deviceInfo);
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int ret = Interop.Tapi.Modem.GetDeviceInfo(_handle, _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get the device vendor name and device name, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            return task.Task;
+        }
+    }
+}
diff --git a/src/Tizen.Tapi/Tizen.Tapi/ModemData.cs b/src/Tizen.Tapi/Tizen.Tapi/ModemData.cs
new file mode 100755 (executable)
index 0000000..a7dfe24
--- /dev/null
@@ -0,0 +1,228 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Tapi
+{
+    /// <summary>
+    /// A class containing information about mobile equipment version.
+    /// </summary>
+    public class MiscVersionInformation
+    {
+        internal byte Version;
+        internal string SwVers;
+        internal string HwVers;
+        internal string CalcDate;
+        internal string ProdCode;
+        internal string Model;
+        internal byte PrlNamNum;
+        internal string PrlVers;
+        internal byte EriNamNum;
+        internal string EriVers;
+        internal MiscVersionInformation()
+        {
+        }
+
+        /// <summary>
+        /// Version mask.
+        /// </summary>
+        public byte VersionMask
+        {
+            get
+            {
+                return Version;
+            }
+        }
+
+        /// <summary>
+        /// Software version.
+        /// </summary>
+        public string SwVersion
+        {
+            get
+            {
+                return SwVers;
+            }
+        }
+
+        /// <summary>
+        /// Hardware version.
+        /// </summary>
+        public string HwVersion
+        {
+            get
+            {
+                return HwVers;
+            }
+        }
+
+        /// <summary>
+        /// Calculation date.
+        /// </summary>
+        public string CalculationDate
+        {
+            get
+            {
+                return CalcDate;
+            }
+        }
+
+        /// <summary>
+        /// Product code.
+        /// </summary>
+        public string ProductCode
+        {
+            get
+            {
+                return ProdCode;
+            }
+        }
+
+        /// <summary>
+        /// Model id.
+        /// </summary>
+        public string ModelId
+        {
+            get
+            {
+                return Model;
+            }
+        }
+
+        /// <summary>
+        /// Number of prl nam fields.
+        /// </summary>
+        public byte PrlNam
+        {
+            get
+            {
+                return PrlNamNum;
+            }
+        }
+
+        /// <summary>
+        /// Prl version (only for CDMA).
+        /// </summary>
+        public string PrlVersion
+        {
+            get
+            {
+                return PrlVers;
+            }
+        }
+
+        /// <summary>
+        /// Number of Eri nam fields.
+        /// </summary>
+        public byte EriNam
+        {
+            get
+            {
+                return EriNamNum;
+            }
+        }
+
+        /// <summary>
+        /// Eri version.
+        /// </summary>
+        public string EriVersion
+        {
+            get
+            {
+                return EriVers;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class containing information about mobile serial number.
+    /// </summary>
+    public class MiscSerialNumberInformation
+    {
+        internal string SzEsn;
+        internal string SzMeid;
+        internal string SzImei;
+        internal string SzImeiSv;
+        internal MiscSerialNumberInformation()
+        {
+        }
+
+        /// <summary>
+        /// Esn number.
+        /// </summary>
+        public string Esn
+        {
+            get
+            {
+                return SzEsn;
+            }
+        }
+
+        /// <summary>
+        /// Meid number.
+        /// </summary>
+        public string MeId
+        {
+            get
+            {
+                return SzMeid;
+            }
+        }
+
+        /// <summary>
+        /// Imei number.
+        /// </summary>
+        public string Imei
+        {
+            get
+            {
+                return SzImei;
+            }
+        }
+
+        /// <summary>
+        /// Imeisv number.
+        /// </summary>
+        public string ImeiSv
+        {
+            get
+            {
+                return SzImeiSv;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class containing device information of cellular dongle.
+    /// </summary>
+    public class MiscDeviceInfo
+    {
+        internal string Vendor;
+        internal string Device;
+        internal MiscDeviceInfo()
+        {
+        }
+
+        /// <summary>
+        /// Vendor name.
+        /// </summary>
+        public string VendorName
+        {
+            get
+            {
+                return Vendor;
+            }
+        }
+
+        /// <summary>
+        /// Device name.
+        /// </summary>
+        public string DeviceName
+        {
+            get
+            {
+                return Device;
+            }
+        }
+    }
+}
index 6b20e99..2b253a4 100755 (executable)
@@ -92,4 +92,27 @@ namespace Tizen.Tapi
         /// </summary>
         Max
     }
+
+    /// <summary>
+    /// Enumeration for flight mode request type.
+    /// </summary>
+    public enum PowerFlightModeResponse
+    {
+        /// <summary>
+        /// Flight mode on success.
+        /// </summary>
+        On = 0x01,
+        /// <summary>
+        /// Flight mode off success.
+        /// </summary>
+        Off,
+        /// <summary>
+        /// Flight mode request fail.
+        /// </summary>
+        Fail,
+        /// <summary>
+        /// Max value.
+        /// </summary>
+        Max
+    }
 }
index 2cc39d2..739661a 100755 (executable)
@@ -53,4 +53,50 @@ namespace Tizen.Tapi
         [MarshalAs(UnmanagedType.LPStr)]
         internal string ImeiSv;
     }
+
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct MiscDeviceInfoStruct
+    {
+        [MarshalAs(UnmanagedType.LPStr)]
+        internal string Vendor;
+        [MarshalAs(UnmanagedType.LPStr)]
+        internal string Device;
+    }
+
+    internal class ModemStructConversions
+    {
+        internal static MiscVersionInformation ConvertVersionStruct(MiscVersionInfoStruct infoStruct)
+        {
+            MiscVersionInformation versionInfo = new MiscVersionInformation();
+            versionInfo.CalcDate = infoStruct.CalDate;
+            versionInfo.EriNamNum = infoStruct.EriNam;
+            versionInfo.EriVers = infoStruct.EriVersion;
+            versionInfo.HwVers = infoStruct.HwVersion;
+            versionInfo.SwVers = infoStruct.SwVersion;
+            versionInfo.PrlNamNum = infoStruct.PrlNam;
+            versionInfo.PrlVers = infoStruct.PrlVersion;
+            versionInfo.ProdCode = infoStruct.ProductCode;
+            versionInfo.Version = infoStruct.Mask;
+            versionInfo.Model = infoStruct.ModelId;
+            return versionInfo;
+        }
+
+        internal static MiscSerialNumberInformation ConvertSerialNumberStruct(MiscSerialNumInfoStruct infoStruct)
+        {
+            MiscSerialNumberInformation serialNumberInfo = new MiscSerialNumberInformation();
+            serialNumberInfo.SzEsn = infoStruct.Esn;
+            serialNumberInfo.SzImei = infoStruct.Imei;
+            serialNumberInfo.SzImeiSv = infoStruct.ImeiSv;
+            serialNumberInfo.SzMeid = infoStruct.MeId;
+            return serialNumberInfo;
+        }
+
+        internal static MiscDeviceInfo ConvertMiscInfoStruct(MiscDeviceInfoStruct infoStruct)
+        {
+            MiscDeviceInfo deviceInfo = new MiscDeviceInfo();
+            deviceInfo.Vendor = infoStruct.Vendor;
+            deviceInfo.Device = infoStruct.Device;
+            return deviceInfo;
+        }
+    }
 }
index 8b9f68f..f2fc8c1 100755 (executable)
@@ -376,4 +376,42 @@ namespace Tizen.Tapi
         Blank
     }
 
+    /// <summary>
+    /// Enumeration for the different network operation causes.
+    /// </summary>
+    public enum NetworkOperationCause
+    {
+        /// <summary>
+        /// No error for any operation.
+        /// </summary>
+        NoError,
+        /// <summary>
+        /// Aborted.
+        /// </summary>
+        Aborted,
+        /// <summary>
+        /// Error.
+        /// </summary>
+        Failed,
+        /// <summary>
+        /// Phone is in use(eg: Voice / Data call in progress).
+        /// </summary>
+        PhoneInUse,
+        /// <summary>
+        /// Phone is in offline mode.
+        /// </summary>
+        Offline,
+        /// <summary>
+        /// Modem is unable to process the config settings information.
+        /// </summary>
+        ConfigSettingsFailure,
+        /// <summary>
+        /// Internal failure.
+        /// </summary>
+        InternalFailure,
+        /// <summary>
+        /// Memory is full.
+        /// </summary>
+        MemoryFull
+    }
 }
diff --git a/src/Tizen.Tapi/Tizen.Tapi/Oem.cs b/src/Tizen.Tapi/Tizen.Tapi/Oem.cs
new file mode 100755 (executable)
index 0000000..e073f1e
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * 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 System.Threading.Tasks;
+
+namespace Tizen.Tapi
+{
+    /// <summary>
+    /// This class provides functions for sending oem related data.
+    /// </summary>
+    public class Oem
+    {
+        private IntPtr _handle;
+        private Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback> _response_map = new Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback>();
+        private int _requestId = 0;
+
+        /// <summary>
+        /// A public constructor for Oem class to create a Oem instance for the given tapi handle.
+        /// </summary>
+        /// <param name="handle">The tapi handle.</param>
+        public Oem(TapiHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException("TapiHandle parameter is null");
+            }
+
+            _handle = handle._handle;
+        }
+
+        /// <summary>
+        /// Sends oem data directly.
+        /// </summary>
+        /// <param name="oemId">Oem id for user specification.</param>
+        /// <param name="data">Oem data for sending.</param>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when oem instance is invalid or when method failed due to invalid operation.</exception>
+        public void SendOemData(int oemId, byte[] data)
+        {
+            int length = data.Length;
+            IntPtr oemData = Marshal.AllocHGlobal(length);
+            Marshal.Copy(data, 0, oemData, length);
+            int ret = Interop.Tapi.Oem.SendOemData(_handle, oemId, oemData, Convert.ToUInt32(length));
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to send oem data directly, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+        }
+
+        /// <summary>
+        /// Sends oem data directly.
+        /// </summary>
+        /// <param name="oemId">Oem id for user specification.</param>
+        /// <param name="data">Oem data for sending.</param>
+        /// <returns>The oem data which is sent.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when call instance is invalid or when method failed due to invalid operation.</exception>
+        public OemData SendOemDataSync(int oemId, byte[] data)
+        {
+            OemDataStruct oemStruct;
+            int length = data.Length;
+            IntPtr oemData = Marshal.AllocHGlobal(length);
+            Marshal.Copy(data, 0, oemData, length);
+            int ret = Interop.Tapi.Oem.SendOemDataSync(_handle, oemId, oemData, Convert.ToUInt32(length), out oemStruct);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to send oem data directly, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            OemData oemDataSend = OemStructConversions.ConvertOemStruct(oemStruct);
+            return oemDataSend;
+        }
+
+        /// <summary>
+        /// Sends oem data directly.
+        /// </summary>
+        /// <param name="oemId">Oem id for user specification.</param>
+        /// <param name="data">Oem data for sending.</param>
+        /// <returns>The oem data which is sent.</returns>
+        /// <privilege>http://tizen.org/privilege/telephony.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/network.telephony</feature>
+        /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception>
+        /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
+        /// <exception cref="System.InvalidOperationException">Thrown when call instance is invalid or when method failed due to invalid operation.</exception>
+        public Task<OemData> SendOemDataAsync(int oemId, byte[] data)
+        {
+            TaskCompletionSource<OemData> task = new TaskCompletionSource<OemData>();
+            IntPtr id;
+            id = (IntPtr)_requestId++;
+            _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) =>
+            {
+                Task resultTask = new Task(() =>
+                {
+                    if (result != (int)NetworkOperationCause.NoError)
+                    {
+                        Log.Error(TapiUtility.LogTag, "Error occurs during sending oem data, " + (NetworkOperationCause)result);
+                        task.SetException(new InvalidOperationException("Error occurs during sending oem data, " + (NetworkOperationCause)result));
+                    }
+
+                    OemDataStruct oemStruct = Marshal.PtrToStructure<OemDataStruct>(dataResponse);
+                    OemData oemClass = OemStructConversions.ConvertOemStruct(oemStruct);
+                    task.SetResult(oemClass);
+                });
+
+                resultTask.Start();
+                resultTask.Wait();
+                _response_map.Remove(key);
+            };
+
+            int length = data.Length;
+            IntPtr oemData = Marshal.AllocHGlobal(length);
+            Marshal.Copy(data, 0, oemData, length);
+            int ret = Interop.Tapi.Oem.SendOemDataAsync(_handle, oemId, oemData, Convert.ToUInt32(length), _response_map[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to send oem data, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+    }
+}
\ No newline at end of file