From: adhavan.m Date: Wed, 28 Jun 2017 13:56:44 +0000 (+0530) Subject: [Tapi] Implementation of Sim class. X-Git-Tag: submit/trunk/20170823.075128~79^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e466d3b56dbb332aeb5b197499a1a1901bcb8bb;hp=4c91fe8bbd6402aa6fe12e77eca976ec942f693c;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Tapi] Implementation of Sim class. Change-Id: I83339109fe2c1128d5e92ec58b9f1d90fe14f322 Signed-off-by: adhavan.m --- diff --git a/src/Tizen.Tapi/Interop/Interop.Tapi.cs b/src/Tizen.Tapi/Interop/Interop.Tapi.cs index ab65fa8..6fcc420 100755 --- a/src/Tizen.Tapi/Interop/Interop.Tapi.cs +++ b/src/Tizen.Tapi/Interop/Interop.Tapi.cs @@ -102,11 +102,11 @@ internal static partial class Interop [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_init_info")] internal static extern int SimGetInitInfo(IntPtr handle, out SimCardStatus status, out int cardChanged); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_type")] - internal static extern int SimGetType(IntPtr handle, out SimType type); + internal static extern int SimGetType(IntPtr handle, out SimCardType type); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_imsi")] internal static extern int SimGetImsi(IntPtr handle, out SimImsiInfoStruct imsiInfo); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_ecc")] - internal static extern int SimGetEcc(IntPtr handle, out SimEccInfoStruct eccInfo); + internal static extern int SimGetEcc(IntPtr handle, out SimEccInfoListStruct eccInfo); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_iccid")] internal static extern int SimGetIccId(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_language")] @@ -116,15 +116,15 @@ internal static partial class Interop [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_callforwarding_info")] internal static extern int SimGetCallForwardingInfo(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_set_sim_callforwarding_info")] - internal static extern int SimSetCallForwardingInfo(IntPtr handle, SimCallForwardRequestStruct request, TapiResponseCallback cb, IntPtr userData); + internal static extern int SimSetCallForwardingInfo(IntPtr handle, ref SimCallForwardRequestStruct request, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_messagewaiting_info")] internal static extern int SimGetMessageWaitingInfo(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_set_sim_messagewaiting_info")] - internal static extern int SimSetMessageWaitingInfo(IntPtr handle, SimMessageWaitingRequestStruct request, TapiResponseCallback cb, IntPtr userData); + internal static extern int SimSetMessageWaitingInfo(IntPtr handle, ref SimMessageWaitingRequestStruct request, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_mailbox_info")] internal static extern int SimGetMailboxInfo(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_set_sim_mailbox_info")] - internal static extern int SimSetMailboxInfo(IntPtr handle, SimMailboxNumberStruct mailbox, TapiResponseCallback cb, IntPtr userData); + internal static extern int SimSetMailboxInfo(IntPtr handle, ref SimMailboxNumberStruct mailbox, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_cphs_info")] internal static extern int SimGetCphsInfo(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_service_table")] @@ -160,7 +160,7 @@ internal static partial class Interop [DllImport(Libraries.Tapi, EntryPoint = "tel_req_sim_atr")] internal static extern int SimRequestAtr(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_application_list")] - internal static extern int SimGetApplicationList(IntPtr handle, out byte appList); + internal static extern int SimGetApplicationList(IntPtr handle, out IntPtr appList); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_impi")] internal static extern int SimGetImpi(IntPtr handle, TapiResponseCallback cb, IntPtr userData); [DllImport(Libraries.Tapi, EntryPoint = "tel_get_sim_impu")] diff --git a/src/Tizen.Tapi/Tizen.Tapi/Sim.cs b/src/Tizen.Tapi/Tizen.Tapi/Sim.cs new file mode 100755 index 0000000..c7d8acc --- /dev/null +++ b/src/Tizen.Tapi/Tizen.Tapi/Sim.cs @@ -0,0 +1,1564 @@ +/* + * 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; +using System.Text; + +namespace Tizen.Tapi +{ + /// + /// A class which manages SIM card services. + /// + public class Sim + { + private IntPtr _handle = IntPtr.Zero; + private Dictionary _callbackMap = new Dictionary(); + private int _requestId = 0; + private Sim() + { + } + + /// + /// A constructor to instantiate Sim class using the Tapi handle. + /// + /// An instance of TapiHandle obtained from InitTapi in TapiManager API. + /// Thrown when handle is passed as null. + public Sim(TapiHandle handle) + { + if (handle == null) + { + throw new ArgumentNullException("Handle is null"); + } + + _handle = handle._handle; + } + + /// + /// Gets SIM card initialization status and SIM card identification. + /// + /// An instance of SimInitInfo class in case of success. Null in case of failure. + public SimInitInfo InitInfo + { + get + { + SimCardStatus status; + int isCardChanged; + int ret = Interop.Tapi.Sim.SimGetInitInfo(_handle, out status, out isCardChanged); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM init info, Error: " + (TapiError)ret); + return null; + } + + SimInitInfo initInfo = new SimInitInfo(); + initInfo.SimStatus = status; + if (isCardChanged == 1) + { + initInfo.IsChanged = true; + } + + else if (isCardChanged == 0) + { + initInfo.IsChanged = false; + } + + return initInfo; + } + } + + /// + /// Gets the card type (SIM/USIM). + /// + public SimCardType SimType + { + get + { + SimCardType type; + int ret = Interop.Tapi.Sim.SimGetType(_handle, out type); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM card type, Error: " + (TapiError)ret); + return default(SimCardType); + } + + return type; + } + } + + /// + /// Gets SIM IMSI information. + /// + public SimImsiInfo Imsi + { + get + { + SimImsiInfoStruct imsi; + int ret = Interop.Tapi.Sim.SimGetImsi(_handle, out imsi); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM IMSI info, Error: " + (TapiError)ret); + return null; + } + + return SimStructConversions.ConvertSimImsiInfoStruct(imsi); + } + } + + /// + /// Gets ECC(SIM) or UECC(USIM) data. + /// + public SimEccInfoList Ecc + { + get + { + SimEccInfoListStruct eccInfo; + int ret = Interop.Tapi.Sim.SimGetEcc(_handle, out eccInfo); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM ECC info, Error: " + (TapiError)ret); + return null; + } + + return SimStructConversions.ConvertSimEccInfoListStruct(eccInfo); + } + } + + /// + /// Gets the list of application on UICC. + /// + /// A byte containing the masking value for SimAppType. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public byte SimGetApplicationList() + { + IntPtr appList; + int ret = Interop.Tapi.Sim.SimGetApplicationList(_handle, out appList); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get list of applications, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return Marshal.ReadByte(appList); + } + + /// + /// Gets the unique identification number of the (U)ICC. + /// + /// A task containing ICCID information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetIccId() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting ICCID info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting ICCID info, " + (SimAccessResult)result)); + } + + SimIccIdInfoStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimIccIdInfoStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetIccId(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM ICCID info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets language preference(indication) information. + /// + /// A task containing information about SIM language preference. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetLanguagePreference() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting language preference: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting language preference, " + (SimAccessResult)result)); + } + + task.SetResult((SimLanguagePreference)Marshal.ReadInt32(data)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetLanguage(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM language preference, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Updates language preference information to the SIM card. + /// + /// The language preference information. + /// A task indicating whether setting of language preference is done or not. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimSetLanguagePreference(SimLanguagePreference language) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in setting language preference: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in setting language preference, " + (SimAccessResult)result)); + } + + task.SetResult(true); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimSetLanguage(_handle, language, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to set SIM language preference, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Gets SIM call forwarding indication related data(EF-CFIS and CPHS case). + /// + /// A task containing call forward response information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetCallForwardInfo() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting call forward info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting call forward info, " + (SimAccessResult)result)); + } + + SimCallForwardResponseStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimCallForwardResponseStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetCallForwardingInfo(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM call forward info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Sets SIM call forwarding indication related data(EF-CFIS and CPHS case). + /// + /// The data requesting for call forwarding. + /// A task indicating whether setting call forward info is done or not. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when call forward request is passed as null. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimSetCallForwardInfo(SimCallForwardRequest request) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in setting call forward info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in setting call forward info, " + (SimAccessResult)result)); + } + + task.SetResult(true); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (request == null) + { + throw new ArgumentNullException("SIM call forward request is null"); + } + + SimCallForwardRequestStruct requestStruct = SimClassConversions.ConvertSimCallForwardRequest(request); + int ret = Interop.Tapi.Sim.SimSetCallForwardingInfo(_handle, ref requestStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to set SIM call forward info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Gets SIM message waiting indication related data(EF-MWIS and CPHS case). + /// + /// A task containing message waiting response information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetMessageWaitingInfo() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting message waiting info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting message waiting info, " + (SimAccessResult)result)); + } + + SimMessageWaitingResponseStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimMessageWaitingRespStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetMessageWaitingInfo(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM message waiting info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Sets SIM message waiting indication related data(EF-MWIS and CPHS case). + /// + /// The data requesting for message waiting. + /// A task indicating whether setting message waiting info is done or not. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when message waiting request is passed as null. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimSetMessageWaitingInfo(SimMessageWaitingRequest request) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in setting message waiting info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in setting message waiting info, " + (SimAccessResult)result)); + } + + task.SetResult(true); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (request == null) + { + throw new ArgumentNullException("SIM message waiting request is null"); + } + + SimMessageWaitingRequestStruct requestStruct = SimClassConversions.ConvertSimMessageWaitingRequest(request); + int ret = Interop.Tapi.Sim.SimSetMessageWaitingInfo(_handle, ref requestStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to set SIM message waiting info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Gets SIM mailbox related data(EF-MBDN, MBDI, and CPHS case). + /// + /// A task containing SimMailboxList information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetMailboxInfo() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting mailbox info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting mailbox info, " + (SimAccessResult)result)); + } + + SimMailboxListStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimMailboxListStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetMailboxInfo(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM mailbox info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Sets SIM mailbox related data(EF-MBDN, MBDI and CPHS case). + /// + /// The data requesting for mailbox info. + /// A task indicating whether setting mailbox info is done or not. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when mailbox number is passed as null. + /// Thrown when the system runs out of memory. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimSetMailboxInfo(SimMailboxNumber mailboxNumber) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in setting mailbox info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in setting mailbox info, " + (SimAccessResult)result)); + } + + task.SetResult(true); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (mailboxNumber == null) + { + throw new ArgumentNullException("SIM mailbox number is null"); + } + + SimMailboxNumberStruct mbStruct = SimClassConversions.ConvertSimMailboxNumber(mailboxNumber); + int ret = Interop.Tapi.Sim.SimSetMailboxInfo(_handle, ref mbStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to set SIM mailbox info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Gets SIM CPHS specific data. + /// + /// A task containing SimCphs information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetCphsInfo() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting CPHS info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting CPHS info, " + (SimAccessResult)result)); + } + + SimCphsInfoStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimCphsInfoStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetCphsInfo(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM CPHS info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets the SIM Service Table. + /// + /// A task containing SIM service table information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetServiceTable() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting service table: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting service table, " + (SimAccessResult)result)); + } + + SimServiceTableStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimServiceTableStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetServiceTable(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM service table, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets SIM MSISDN data. + /// + /// A task containing SimMsisdnList information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetMsisdn() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting MSISDN info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting MSISDN info, " + (SimAccessResult)result)); + } + + SimMsisdnListStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimMsisdnListStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetMsisdn(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM MSISDN data, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets SIM OPLMNWACT(Operator controlled PLMN Selector with Access Technology) data. + /// + /// A task containing SimOplmnwactList information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetOplmnwact() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting OPLMNWACT info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting OPLMNWACT info, " + (SimAccessResult)result)); + } + + SimOplmnwactListStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimOplmnwactListStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetOplmnwact(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM OPLMNWACT info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets SIM SPN data. + /// + /// A task containing SimSpn information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetSpn() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SPN info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SPN info, " + (SimAccessResult)result)); + } + + SimSpnStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimSpnStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetSpn(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM SPN info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets SIM CPHS NETNAME data. + /// + /// A task containing SimCphsNetName information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetCphsNetName() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting CPHS netname info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting CPHS netname info, " + (SimAccessResult)result)); + } + + SimCphsNetNameStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimCphsNetNameStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetCphsNetName(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM CPHS netname info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Executes an authentication procedure by using SIM. + /// + /// The authentication code to be validated by the ISIM, 3G, and GSM application in the SIM card. + /// A task containing SimAuthenticationResponse information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when authentication data is passed as null. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimExecuteAuthentication(SimAuthenticationData authenticationData) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in executing authentication procedure: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in executing authentication procedure, " + (SimAccessResult)result)); + } + + SimAuthenticationResponseStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimAuthenticationResponseStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (authenticationData == null) + { + throw new ArgumentNullException("SIM authentication data is null"); + } + + SimAuthenticationDataStruct authStruct = SimClassConversions.ConvertSimAuthenticationDataStruct(authenticationData); + int ret = Interop.Tapi.Sim.SimExecuteAuthentication(_handle, ref authStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to execute authentication procedure, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Performs PIN1/PIN2/SIM LOCK verification. + /// + /// The PIN code. + /// A task containing SimPinResult information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when pin data is passed as null. + /// Thrown when the system runs out of memory. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimVerifyPins(SimPinData pinData) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in verifying SIM pins: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in verifying SIM pins, " + (SimAccessResult)result)); + } + + SimPinResultStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimPinResultStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (pinData == null) + { + throw new ArgumentNullException("SIM PIN data is null"); + } + + SimPinDataStruct pinStruct = SimClassConversions.ConvertSimPinData(pinData); + int ret = Interop.Tapi.Sim.SimVerifyPins(_handle, ref pinStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to verify SIM PIN, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Performs PIN1/PIN2 unblocking operation based on PUK information. + /// + /// The unblocking PIN password. + /// The PIN password to use after the unblocking operation. + /// A task containing SimPinResult information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when either of pukData or newPinData is passed as null. + /// Thrown when the system runs out of memory. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimVerifyPuks(SimPinData pukData, SimPinData newPinData) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in verifying SIM puks: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in verifying SIM puks, " + (SimAccessResult)result)); + } + + SimPinResultStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimPinResultStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (pukData == null || newPinData == null) + { + throw new ArgumentNullException("SIM PIN/PUK data is null"); + } + + SimPinDataStruct pukStruct = SimClassConversions.ConvertSimPinData(pukData); + SimPinDataStruct pinStruct = SimClassConversions.ConvertSimPinData(newPinData); + int ret = Interop.Tapi.Sim.SimVerifyPuks(_handle, ref pukStruct, ref pinStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to verify SIM puks, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Changes the PIN1/PIN2 code based on the PIN type passed along with old PIN data and new PIN data. + /// + /// The old PIN code entered by the user. + /// The new PIN code entered by the user. + /// A task containing SimPinResult information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when either of oldPin or newPin is passed as null. + /// Thrown when the system runs out of memory. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimChangePins(SimPinData oldPin, SimPinData newPin) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in changing SIM pins: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in changing SIM pins, " + (SimAccessResult)result)); + } + + SimPinResultStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimPinResultStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (oldPin == null || newPin == null) + { + throw new ArgumentNullException("Old/new PIN data is null"); + } + + SimPinDataStruct oldPinStruct = SimClassConversions.ConvertSimPinData(oldPin); + SimPinDataStruct newPinStruct = SimClassConversions.ConvertSimPinData(newPin); + int ret = Interop.Tapi.Sim.SimChangePins(_handle, ref oldPinStruct, ref newPinStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to change SIM pins, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Disables the SIM facility. + /// + /// An object which contains the facility type and password. + /// A task containing SIM facility result information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when SIM facility info is passed as null. + /// Thrown when the system runs out of memory. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimDisableFacility(SimFacility facility) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in disabling SIM facility: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in disabling SIM facility, " + (SimAccessResult)result)); + } + + SimFacilityResultStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimFacilityResultStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (facility == null) + { + throw new ArgumentNullException("SIM facility info is null"); + } + + SimFacilityStruct facilityStruct = SimClassConversions.ConvertSimFacility(facility); + int ret = Interop.Tapi.Sim.SimDisableFacility(_handle, ref facilityStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to disable SIM facility, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Enables the SIM facility. + /// + /// An object which contains the facility type and password. + /// A task containing SIM facility result information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when SIM facility info is passed as null. + /// Thrown when the system runs out of memory. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimEnableFacility(SimFacility facility) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in enabling SIM facility: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in enabling SIM facility, " + (SimAccessResult)result)); + } + + SimFacilityResultStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimFacilityResultStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (facility == null) + { + throw new ArgumentNullException("SIM facility info is null"); + } + + SimFacilityStruct facilityStruct = SimClassConversions.ConvertSimFacility(facility); + int ret = Interop.Tapi.Sim.SimEnableFacility(_handle, ref facilityStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to enable SIM facility, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Gets the SIM facility. + /// + /// The type of security lock. + /// A task containing SIM facility information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetFacility(SimLockType lockType) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM facility: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SIM facility, " + (SimAccessResult)result)); + } + + SimFacilityInfoStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimFacilityInfoStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetFacility(_handle, lockType, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM facility, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets SIM lock type info. + /// + /// The type of security lock. + /// A task containing SIM lock information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetLockInfo(SimLockType lockType) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM lock info: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SIM lock info, " + (SimAccessResult)result)); + } + + SimLockInfoStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimLockInfoStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetLockInfo(_handle, lockType, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM lock info, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Sets the SIM power state. + /// + /// The state of SIM to be set. + /// A task indicating whether setting SIM power state is done or not. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimSetPowerState(SimPowerState state) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimPowerSetResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in setting SIM power state: " + (SimPowerSetResult)result); + task.SetException(new InvalidOperationException("Error occurs in setting SIM power state, " + (SimPowerSetResult)result)); + } + + task.SetResult(true); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimSetPowerState(_handle, state, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to set SIM power state, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Provides a common interface for accessing SIM data. + /// + /// The APDU data. + /// A task containing SIM APDU response information. + /// http://tizen.org/feature/network.telephony + /// platform + /// http://tizen.org/privilege/telephony.admin + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when SIM APDU is passed as null. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimRequestApdu(SimApdu apdu) + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in requesting SIM APDU: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in requesting SIM APDU, " + (SimAccessResult)result)); + } + + SimApduResponseStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimApduResponseStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + if (apdu == null) + { + throw new ArgumentNullException("SIM APDU is null"); + } + + SimApduStruct apduStruct = SimClassConversions.ConvertSimApdu(apdu); + int ret = Interop.Tapi.Sim.SimRequestApdu(_handle, ref apduStruct, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to request SIM APDU, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); + } + + return task.Task; + } + + /// + /// Provides a common interface to get the SIM ATR(Answer To Reset) value. + /// + /// A task containing SIM ATR response information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimRequestAtr() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in requesting SIM ATR: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in requesting SIM ATR, " + (SimAccessResult)result)); + } + + SimAtrResponseStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimAtrResponseStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimRequestAtr(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to request SIM ATR, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets the IMPI(IMS private user identity). (ISIM only). + /// + /// A task containing IMPI string. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetImpi() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM IMPI: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SIM IMPI, " + (SimAccessResult)result)); + } + + task.SetResult(Marshal.PtrToStringAnsi(data)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetImpi(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM IMPI, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets the IMPU(IMS public user identity). (ISIM only). + /// + /// A task containing SIM IMPU list information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetImpu() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM IMPU: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SIM IMPU, " + (SimAccessResult)result)); + } + + SimImpuListStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimImpuListStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetImpu(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM IMPU, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets the Domain(Home Network Domain Name). (ISIM only) + /// + /// A task containing domain string. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetDomain() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM domain: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SIM domain, " + (SimAccessResult)result)); + } + + task.SetResult(Marshal.PtrToStringAnsi(data)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetDomain(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM domain, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets the P-CSCF(Proxy Call Session Control Function). (ISIM only) + /// + /// A task containing SIM PCSCF list information. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetPcscf() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting SIM PCSCF: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting SIM PCSCF, " + (SimAccessResult)result)); + } + + SimPcscfListStruct info = Marshal.PtrToStructure(data); + task.SetResult(SimStructConversions.ConvertSimPcscfListStruct(info)); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetPcscf(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get SIM PCSCF, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + + /// + /// Gets the ISIM service table. (ISIM only). + /// + /// A task containing a byte array in which mask value of SimIsimService enum will be stored. + /// http://tizen.org/feature/network.telephony + /// http://tizen.org/privilege/telephony + /// Thrown when telephony feature is not supported. + /// Thrown when privilege access is denied. + /// Thrown when it is failed due to invalid parameter. + /// Thrown when it is failed due to invalid operation. + public Task SimGetIsimServiceTable() + { + TaskCompletionSource task = new TaskCompletionSource(); + IntPtr id = (IntPtr)_requestId++; + _callbackMap[id] = (handle, result, data, key) => + { + Task taskResult = new Task(() => + { + if (result != (int)SimAccessResult.Success) + { + Log.Error(TapiUtility.LogTag, "Error occurs in getting ISIM service table: " + (SimAccessResult)result); + task.SetException(new InvalidOperationException("Error occurs in getting ISIM service table, " + (SimAccessResult)result)); + } + + task.SetResult(Encoding.ASCII.GetBytes(Marshal.PtrToStringAnsi(data))); + }); + taskResult.Start(); + taskResult.Wait(); + _callbackMap.Remove(key); + }; + + int ret = Interop.Tapi.Sim.SimGetIsimServiceTable(_handle, _callbackMap[id], id); + if (ret != (int)TapiError.Success) + { + Log.Error(TapiUtility.LogTag, "Failed to get ISIM service table, Error: " + (TapiError)ret); + TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); + } + + return task.Task; + } + } +} diff --git a/src/Tizen.Tapi/Tizen.Tapi/SimData.cs b/src/Tizen.Tapi/Tizen.Tapi/SimData.cs new file mode 100755 index 0000000..f378ab8 --- /dev/null +++ b/src/Tizen.Tapi/Tizen.Tapi/SimData.cs @@ -0,0 +1,2247 @@ +/* + * 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.Collections.Generic; + +namespace Tizen.Tapi +{ + /// + /// A class which defines SIM card initialization information. + /// + public class SimInitInfo + { + internal SimCardStatus SimStatus; + internal bool IsChanged; + internal SimInitInfo() + { + } + + /// + /// The SIM initialization status from the Telephony server boot up time. + /// + public SimCardStatus Status + { + get + { + return SimStatus; + } + } + + /// + /// The SIM card identification value. It will be true when the current inserted SIM card differs from the previous SIM. False otherwise. + /// + public bool IsCardChanged + { + get + { + return IsChanged; + } + } + } + + /// + /// A class which defines data for IMSI information. + /// + public class SimImsiInfo + { + internal string CountryCode; + internal string NetworkCode; + internal string StationId; + internal SimImsiInfo() + { + } + + /// + /// Mobile Country Code. + /// + public string Mcc + { + get + { + return CountryCode; + } + } + + /// + /// Mobile Network Code. + /// + public string Mnc + { + get + { + return NetworkCode; + } + } + + /// + /// Mobile Station Identification Number. + /// + public string Msin + { + get + { + return StationId; + } + } + } + + /// + /// A class which defines data for ECC information of GSM/USIM/CDMA SIM. + /// + public class SimEccInfo + { + internal string NameInfo; + internal string NumberInfo; + internal SimEccEmergencyServiceType TypeInfo; + internal SimEccInfo() + { + } + + /// + /// Name. Applicable only for USIM(3G) SIM. + /// + public string Name + { + get + { + return NameInfo; + } + } + + /// + /// Number. + /// + public string Number + { + get + { + return NumberInfo; + } + } + + /// + /// Emergency service type. Applicable only for USIM(3G) SIM. + /// + public SimEccEmergencyServiceType Category + { + get + { + return TypeInfo; + } + } + } + + /// + /// A class which defines ECC information list. + /// + public class SimEccInfoList + { + internal int EccCount; + internal IEnumerable List; + internal SimEccInfoList() + { + } + + /// + /// ECC count. + /// + public int Count + { + get + { + return EccCount; + } + } + + /// + /// List of ECC. + /// + public IEnumerable EccList + { + get + { + return List; + } + } + } + + /// + /// A class which defines ICCID(Integrated Circuit Card Identifier). + /// + public class SimIccIdInfo + { + internal int Length; + internal string Number; + internal SimIccIdInfo() + { + } + + /// + /// Integrated Circuit Card number length. + /// + public int IccLength + { + get + { + return Length; + } + } + + /// + /// Integrated Circuit Card number. + /// + public string IccNumber + { + get + { + return Number; + } + } + } + + /// + /// A class which defines call forwarding indication status data. + /// + public class SimCfis + { + private int _recIndex; + private byte _mspNum; + private byte _cfuStatus; + private SimTypeOfNumber _ton; + private SimNumberPlanIdentity _npi; + private string _cfuNum; + private byte _cc2Id; + private byte _ext7Id; + + /// + /// Record index. + /// + public int RecIndex + { + get + { + return _recIndex; + } + + set + { + _recIndex = value; + } + } + + /// + /// MSP number. + /// + public byte MspNum + { + get + { + return _mspNum; + } + + set + { + _mspNum = value; + } + } + + /// + /// Call forwarding unconditional indication status. + /// + public byte CfuStatus + { + get + { + return _cfuStatus; + } + + set + { + _cfuStatus = value; + } + } + + /// + /// SIM Type of number. + /// + public SimTypeOfNumber Ton + { + get + { + return _ton; + } + + set + { + _ton = value; + } + } + + /// + /// SIM numbering plan identity. + /// + public SimNumberPlanIdentity Npi + { + get + { + return _npi; + } + + set + { + _npi = value; + } + } + + /// + /// Dialing Number/SSC String. + /// + public string CfuNum + { + get + { + return _cfuNum; + } + + set + { + _cfuNum = value; + } + } + + /// + /// Capability/Configuration 2 Record Identifier. + /// + public byte Cc2Id + { + get + { + return _cc2Id; + } + + set + { + _cc2Id = value; + } + } + + /// + /// Extension 7 Record Identifier. + /// + public byte Ext7Id + { + get + { + return _ext7Id; + } + + set + { + _ext7Id = value; + } + } + } + + /// + /// A class which defines call forwarding indication status list. + /// + public class SimCfisList + { + internal int Count; + internal IEnumerable List; + internal SimCfisList() + { + } + + /// + /// Profile count. + /// + public int ProfileCount + { + get + { + return Count; + } + } + + /// + /// List of CFIS. + /// + public IEnumerable CfisList + { + get + { + return List; + } + } + } + + /// + /// A class which defines CPHS call forwarding status data. + /// + public class SimCphsCf + { + private int _line1; + private int _line2; + private int _fax; + private int _data; + + /// + /// CallForwardUnconditionalLine 1. + /// + public int Line1 + { + get + { + return _line1; + } + + set + { + _line1 = value; + } + } + + /// + /// CallForwardUnconditionalLine 2. + /// + public int Line2 + { + get + { + return _line2; + } + + set + { + _line2 = value; + } + } + + /// + /// CallForwardUnconditional Fax. + /// + public int Fax + { + get + { + return _fax; + } + + set + { + _fax = value; + } + } + + /// + /// CallForwardUnconditional data. + /// + public int Data + { + get + { + return _data; + } + + set + { + _data = value; + } + } + } + + /// + /// A class which defines call forwarding response. + /// + public class SimCallForwardResponse + { + internal bool IsCphsCf; + internal SimCfisList List; + internal SimCphsCf CphsCfInfo; + internal SimCallForwardResponse() + { + } + + /// + /// CPHS or not. + /// + public bool IsCphs + { + get + { + return IsCphsCf; + } + } + + /// + /// List of CFIS. + /// + public SimCfisList CfList + { + get + { + return List; + } + } + + /// + /// CPHS CF. + /// + public SimCphsCf CphsCf + { + get + { + return CphsCfInfo; + } + } + } + + /// + /// A class which defines call forwarding request. + /// + public class SimCallForwardRequest + { + private bool _isCphs; + private SimCfis _cfis; + private SimCphsCf _cphsCf; + + /// + /// CPHS or not. + /// + public bool IsCphs + { + get + { + return _isCphs; + } + + set + { + _isCphs = value; + } + } + + /// + /// CFIS. + /// + /// + /// This should be filled only if IsCphs is false. + /// + public SimCfis Cfis + { + get + { + return _cfis; + } + + set + { + _cfis = value; + } + } + + /// + /// CPHS CF. + /// + /// + /// This should be filled only if IsCphs is true. + /// + public SimCphsCf CphsCf + { + get + { + return _cphsCf; + } + + set + { + _cphsCf = value; + } + } + } + + /// + /// A class which defines message waiting indication status data. + /// + public class SimMwis + { + private int _recIndex; + private byte _indicatorStatus; + private int _voiceCount; + private int _faxCount; + private int _emailCount; + private int _otherCount; + private int _videoCount; + + /// + /// Record index. + /// + public int RecIndex + { + get + { + return _recIndex; + } + + set + { + _recIndex = value; + } + } + + /// + /// Indicator type. + /// + public byte IndicatorStatus + { + get + { + return _indicatorStatus; + } + + set + { + _indicatorStatus = value; + } + } + + /// + /// VoiceMail count. + /// + public int VoiceCount + { + get + { + return _voiceCount; + } + + set + { + _voiceCount = value; + } + } + + /// + /// Fax count. + /// + public int FaxCount + { + get + { + return _faxCount; + } + + set + { + _faxCount = value; + } + } + + /// + /// Email count. + /// + public int EmailCount + { + get + { + return _emailCount; + } + + set + { + _emailCount = value; + } + } + + /// + /// Other count. + /// + public int OtherCount + { + get + { + return _otherCount; + } + + set + { + _otherCount = value; + } + } + + /// + /// VideoMail count. + /// + public int VideoCount + { + get + { + return _videoCount; + } + + set + { + _videoCount = value; + } + } + } + + /// + /// A class which defines message waiting indication status list. + /// + public class SimMwisList + { + internal int Count; + internal IEnumerable List; + internal SimMwisList() + { + } + + /// + /// Profile count. + /// + public int ProfileCount + { + get + { + return Count; + } + } + + /// + /// List of MWIS. + /// + public IEnumerable MwList + { + get + { + return List; + } + } + } + + /// + /// A class which defines CPHS message waiting status data. + /// + public class SimCphsMw + { + private bool _isVoice1; + private bool _isVoice2; + private bool _isFax; + private bool _isData; + + /// + /// VoiceMsgLine1 message waiting flag. + /// + public bool IsVoice1 + { + get + { + return _isVoice1; + } + + set + { + _isVoice1 = value; + } + } + + /// + /// VoiceMsgLine2 message waiting flag. + /// + public bool IsVoice2 + { + get + { + return _isVoice2; + } + + set + { + _isVoice2 = value; + } + } + + /// + /// FAX message waiting flag. + /// + public bool IsFax + { + get + { + return _isFax; + } + + set + { + _isFax = value; + } + } + + /// + /// Data message waiting flag. + /// + public bool IsData + { + get + { + return _isData; + } + + set + { + _isData = value; + } + } + } + + /// + /// A class which defines message waiting reponse. + /// + public class SimMessageWaitingResponse + { + internal bool IsCphsMw; + internal SimMwisList List; + internal SimCphsMw CphsMwInfo; + internal SimMessageWaitingResponse() + { + } + + /// + /// CPHS or not. + /// + public bool IsCphs + { + get + { + return IsCphsMw; + } + } + + /// + /// List of MWIS. + /// + public SimMwisList MwList + { + get + { + return List; + } + } + + /// + /// CPHS MW. + /// + public SimCphsMw CphsMw + { + get + { + return CphsMwInfo; + } + } + } + + /// + /// A class which defines message waiting request. + /// + public class SimMessageWaitingRequest + { + private bool _isCphs; + private SimMwis _mwis; + private SimCphsMw _cphsMw; + + /// + /// CPHS or not. + /// + public bool IsCphs + { + get + { + return _isCphs; + } + + set + { + _isCphs = value; + } + } + + /// + /// MWIS. + /// + /// + /// This should be filled only if IsCphs is false. + /// + public SimMwis Mwis + { + get + { + return _mwis; + } + + set + { + _mwis = value; + } + } + + /// + /// CPHS MW. + /// + /// + /// This should be filled only if IsCphs is true. + /// + public SimCphsMw CphsMw + { + get + { + return _cphsMw; + } + + set + { + _cphsMw = value; + } + } + } + + /// + /// A class which defines mailbox dialing number data. + /// + public class SimMailboxNumber + { + private bool _isCphs; + private int _recIndex; + private int _profileNumber; + private SimMailboxType _mbType; + private int _alphaMaxLength; + private string _alphaId; + private SimTypeOfNumber _ton; + private SimNumberPlanIdentity _npi; + private string _number; + private byte _ccId; + private byte _ext1Id; + + /// + /// CPHS or not. + /// + public bool IsCphs + { + get + { + return _isCphs; + } + + set + { + _isCphs = value; + } + } + + /// + /// Index which stands for the location where the record is saved in SIM. + /// + public int RecIndex + { + get + { + return _recIndex; + } + + set + { + _recIndex = value; + } + } + + /// + /// SIM profile index. + /// + public int ProfileNumber + { + get + { + return _profileNumber; + } + + set + { + _profileNumber = value; + } + } + + /// + /// Mailbox type. + /// + public SimMailboxType MbType + { + get + { + return _mbType; + } + + set + { + _mbType = value; + } + } + + /// + /// Alpha max length in SIM. + /// + public int AlphaMaxLength + { + get + { + return _alphaMaxLength; + } + + set + { + _alphaMaxLength = value; + } + } + + /// + /// Alpha Identifier. + /// + public string AlphaId + { + get + { + return _alphaId; + } + + set + { + _alphaId = value; + } + } + + /// + /// Type Of Number. + /// + public SimTypeOfNumber Ton + { + get + { + return _ton; + } + + set + { + _ton = value; + } + } + + /// + /// Number Plan Identity. + /// + public SimNumberPlanIdentity Npi + { + get + { + return _npi; + } + + set + { + _npi = value; + } + } + + /// + /// Dialing Number/SSC String. + /// + public string Number + { + get + { + return _number; + } + + set + { + _number = value; + } + } + + /// + /// Capability/Configuration Identifier. + /// + public byte CcId + { + get + { + return _ccId; + } + + set + { + _ccId = value; + } + } + + /// + /// Extension 1 Record Identifier. + /// + public byte Ext1Id + { + get + { + return _ext1Id; + } + + set + { + _ext1Id = value; + } + } + } + + /// + /// A class which defines mailbox dialing number list. + /// + public class SimMailboxList + { + internal int MbCount; + internal IEnumerable MbList; + internal SimMailboxList() + { + } + + /// + /// Mailbox count. + /// + public int Count + { + get + { + return MbCount; + } + } + + /// + /// List of mailbox. + /// + public IEnumerable List + { + get + { + return MbList; + } + } + } + + /// + /// A class which defines available optional CPHS SIM files. + /// + public class SimCphsServiceTable + { + internal int CustomerSvcProfile; + internal int SvcStringTable; + internal int MbNumbers; + internal int OperatorNameShort; + internal int InformationNum; + internal SimCphsServiceTable() + { + } + + /// + /// Customer Service Profile (CSP). + /// + public int CustomerServiceProfile + { + get + { + return CustomerSvcProfile; + } + } + + /// + /// Service String Table (SST). + /// + public int ServiceStringTable + { + get + { + return SvcStringTable; + } + } + + /// + /// MailBoxNumbers. + /// + public int MailboxNumbers + { + get + { + return MbNumbers; + } + } + + /// + /// Short form of operator name. + /// + public int OperatorNameShortForm + { + get + { + return OperatorNameShort; + } + } + + /// + /// Information numbers. + /// + public int InformationNumbers + { + get + { + return InformationNum; + } + } + } + + /// + /// A class which defines CPHS information data. + /// + public class SimCphsInfo + { + internal SimCphsPhaseType Phase; + internal SimCphsServiceTable CphsSvcTable; + internal SimCphsInfo() + { + } + + /// + /// CPHS phase type. + /// + public SimCphsPhaseType CphsPhase + { + get + { + return Phase; + } + } + + /// + /// CPHS service table. + /// + public SimCphsServiceTable CphsServiceTable + { + get + { + return CphsSvcTable; + } + } + } + + /// + /// A class which defines CSIM service table. + /// + public class SimCst + { + internal SimCdmaServiceTable CdmaSvc; + internal byte[] Cdma; + internal byte[] Csim; + internal SimCst() + { + } + + /// + /// Cdma service table; + /// + public SimCdmaServiceTable CdmaSvcTable + { + get + { + return CdmaSvc; + } + } + + /// + /// Cdma service. Gives mask value of SimCdmaService enum. + /// + /// + /// This will be filled only if CdmaSvcTable is Cdma. + /// + public byte[] CdmaService + { + get + { + return Cdma; + } + } + + /// + /// Csim service. Gives mask value of SimCsimService enum. + /// + /// + /// This will be filled only if CdmaSvcTable is Csim. + /// + public byte[] CsimService + { + get + { + return Csim; + } + } + } + + /// + /// A class which defines SIM service table. + /// + public class SimServiceTable + { + internal SimCardType Type; + internal byte[] Sst; + internal byte[] Ust; + internal SimCst Cst; + internal SimServiceTable() + { + } + + /// + /// SIM card type. + /// + public SimCardType SimType + { + get + { + return Type; + } + } + + /// + /// SIM service table. Gives mask value of SimSstService enum. + /// + /// + /// This will be filled only if SimType is Gsm. + /// + public byte[] SstService + { + get + { + return Sst; + } + } + + /// + /// USIM service table. Gives mask value of SimUstService enum. + /// + /// + /// This will be filled only if SimType is Usim. + /// + public byte[] UstService + { + get + { + return Ust; + } + } + + /// + /// CSIM service table. + /// + /// + /// This will be filled only if SimType is Ruim. + /// + public SimCst CstService + { + get + { + return Cst; + } + } + } + + /// + /// A class which defines MSISDN information of the GSM/CDMA SIM. + /// + public class SimSubscriberInfo + { + internal string MsisdnNum; + internal string MsisdnName; + internal SimSubscriberInfo() + { + } + + /// + /// MSISDN number. If it does not exist, a null string will be returned + /// + public string Number + { + get + { + return MsisdnNum; + } + } + + /// + /// MSISDN name. If it does not exist, a null string will be returned. Not applicable for CDMA. + /// + public string Name + { + get + { + return MsisdnName; + } + } + } + + /// + /// A class which defines MSISDN list. + /// + public class SimMsisdnList + { + internal int MsisdnCount; + internal IEnumerable SubscriberList; + internal SimMsisdnList() + { + } + + /// + /// Count. + /// + public int Count + { + get + { + return MsisdnCount; + } + } + + /// + /// List of subscriber info. + /// + public IEnumerable List + { + get + { + return SubscriberList; + } + } + } + + /// + /// A class which defines OPLMNwACT data. + /// + public class SimOplmnwact + { + internal string PlmnString; + internal bool UmtsFlag; + internal bool GsmFlag; + internal SimOplmnwact() + { + } + + /// + /// PLMN. + /// + public string Plmn + { + get + { + return PlmnString; + } + } + + /// + /// UMTS or not. + /// + public bool IsUmts + { + get + { + return UmtsFlag; + } + } + + /// + /// GSM or not. + /// + public bool IsGsm + { + get + { + return GsmFlag; + } + } + } + + /// + /// A class which defines OPLMNwACT list. + /// + public class SimOplmnwactList + { + internal int OplmnCount; + internal IEnumerable OplmnList; + internal SimOplmnwactList() + { + } + + /// + /// Count. + /// + public int Count + { + get + { + return OplmnCount; + } + } + + /// + /// List of OPLMNWACT. + /// + public IEnumerable List + { + get + { + return OplmnList; + } + } + } + + /// + /// A class which defines SPN(Service Provider Name). + /// + public class SimSpn + { + internal byte Condition; + internal string SpName; + internal SimSpn() + { + } + + /// + /// Display condition. + /// + public byte DisplayCondition + { + get + { + return Condition; + } + } + + /// + /// Service Provider Name. + /// + public string Spn + { + get + { + return SpName; + } + } + } + + /// + /// A class which defines CPHS network name. + /// + public class SimCphsNetName + { + internal string Full; + internal string Short; + internal SimCphsNetName() + { + } + + /// + /// Full name. + /// + public string FullName + { + get + { + return Full; + } + } + + /// + /// Short name. + /// + public string ShortName + { + get + { + return Short; + } + } + } + + /// + /// A class which defines authentication request data. + /// + public class SimAuthenticationData + { + private SimAuthenticationType _authType; + private int _randLength; + private int _autnLength; + private byte[] _randData; + private byte[] _autnData; + private SimAuthenticationData() + { + } + + /// + /// A constructor to instantiate SimAuthenticationData class with necessary parameters. + /// + /// Authentication type. + /// The length of RAND. + /// The length of AUTN. It is not used in case of GSM AUTH. + /// RAND data. + /// AUTN data. It is not used in case of GSM AUTH. + public SimAuthenticationData(SimAuthenticationType authType, int randLength, int autnLength, byte[] randData, byte[] autnData) + { + _authType = authType; + _randLength = randLength; + _autnLength = autnLength; + _randData = randData; + _autnData = autnData; + } + + internal SimAuthenticationType AuthType + { + get + { + return _authType; + } + } + + internal int RandLength + { + get + { + return _randLength; + } + } + + internal int AutnLength + { + get + { + return _autnLength; + } + } + + internal byte[] RandData + { + get + { + return _randData; + } + } + + internal byte[] AutnData + { + get + { + return _autnData; + } + } + } + + /// + /// A class which defines authentication result data. + /// + public class SimAuthenticationResponse + { + internal SimAuthenticationType Type; + internal SimAuthenticationResult Result; + internal int RespLength; + internal string RespData; + internal int AuthKeyLen; + internal string Key; + internal int CipherLen; + internal string Cipher; + internal int IntegrityLen; + internal string Integrity; + internal SimAuthenticationResponse() + { + } + + /// + /// Authentication type. + /// + public SimAuthenticationType AuthType + { + get + { + return Type; + } + } + + /// + /// Authentication result. + /// + public SimAuthenticationResult AuthResult + { + get + { + return Result; + } + } + + /// + /// Response length. + /// + public int ResponseLength + { + get + { + return RespLength; + } + } + + /// + /// Response data. + /// + public string ResponseData + { + get + { + return RespData; + } + } + + /// + /// The length of the authentication key. + /// + public int AuthKeyLength + { + get + { + return AuthKeyLen; + } + } + + /// + /// The data of the authentication key. + /// + public string AuthKey + { + get + { + return Key; + } + } + + /// + /// The length of the cipher key. + /// + public int CipherLength + { + get + { + return CipherLen; + } + } + + /// + /// Cipher key. + /// + public string CipherData + { + get + { + return Cipher; + } + } + + /// + /// The length of the integrity key. + /// + public int IntegrityLength + { + get + { + return IntegrityLen; + } + } + + /// + /// Integrity key. + /// + public string IntegrityData + { + get + { + return Integrity; + } + } + } + + /// + /// A class which defines information about SIM PIN data. + /// + public class SimPinData + { + private SimPinType _type; + private string _pin; + private uint _pinLength; + private SimPinData() + { + } + + /// + /// A constructor to instantiate SimPinData class which necessary parameters. + /// + /// PIN type. + /// PIN code. + /// PIN code length. + public SimPinData(SimPinType type, string pin, uint pinLength) + { + _type = type; + _pin = pin; + _pinLength = pinLength; + } + + internal SimPinType Type + { + get + { + return _type; + } + } + + internal string Pin + { + get + { + return _pin; + } + } + + internal uint PinLength + { + get + { + return _pinLength; + } + } + } + + /// + /// A class which defines PIN information. + /// + public class SimPinResult + { + internal SimPinType PinType; + internal int Retry; + internal SimPinResult() + { + } + + /// + /// Specifies the PIN or PUK type. + /// + public SimPinType Type + { + get + { + return PinType; + } + } + + /// + /// Number of attempts remaining for PIN/PUK verification. + /// + public int RetryCount + { + get + { + return Retry; + } + } + } + + /// + /// A class which is used to used to enable/disable facility. + /// + public class SimFacility + { + private SimLockType _lockType; + private string _password; + private int _passwordLength; + private SimFacility() + { + } + + /// + /// A constructor to instantiate SimFacility class with necessary parameters. + /// + /// Facility type. + /// Password. + /// Password length. + public SimFacility(SimLockType lockType, string password, int passwordLength) + { + _lockType = lockType; + _password = password; + _passwordLength = passwordLength; + } + + internal SimLockType LockType + { + get + { + return _lockType; + } + } + + internal string Password + { + get + { + return _password; + } + } + + internal int PasswordLength + { + get + { + return _passwordLength; + } + } + } + + /// + /// A class which defines facility result data. + /// + public class SimFacilityResult + { + internal SimLockType LockType; + internal int Count; + internal SimFacilityResult() + { + } + + /// + /// Specifies the PIN or PUK type. + /// + public SimLockType Type + { + get + { + return LockType; + } + } + + /// + /// Number of attempts remaining for PIN/PUK verification. + /// + public int RetryCount + { + get + { + return Count; + } + } + } + + /// + /// A class which defines facility info data. + /// + public class SimFacilityInfo + { + internal SimLockType LockType; + internal SimFacilityStatus FacilityStatus; + internal SimFacilityInfo() + { + } + + /// + /// Lock type. + /// + public SimLockType Type + { + get + { + return LockType; + } + } + + /// + /// Facility status. + /// + public SimFacilityStatus Status + { + get + { + return FacilityStatus; + } + } + } + + /// + /// A class which defines information about lock type. + /// + public class SimLockInfo + { + internal SimLockType LockType; + internal SimLockStatus LockStatus; + internal int Count; + internal SimLockInfo() + { + } + + /// + /// Lock type. + /// + public SimLockType Type + { + get + { + return LockType; + } + } + + /// + /// Lock status. + /// + public SimLockStatus Status + { + get + { + return LockStatus; + } + } + + /// + /// Retry counts. + /// + public int RetryCount + { + get + { + return Count; + } + } + } + + /// + /// A class which defines APDU information. + /// + public class SimApdu + { + private ushort _apduLength; + private byte[] _apdu; + private SimApdu() + { + } + + /// + /// A constructor to instantiate SimApdu class with necessary parameters. + /// + /// Length of APDU. + /// APDU. + public SimApdu(ushort apduLength, byte[] apdu) + { + _apduLength = apduLength; + _apdu = apdu; + } + + internal ushort ApduLength + { + get + { + return _apduLength; + } + } + + internal byte[] Apdu + { + get + { + return _apdu; + } + } + } + + /// + /// A class which defines the response of sending APDU. + /// + public class SimApduResponse + { + internal ushort ApduLen; + internal byte[] ApduResp; + internal SimApduResponse() + { + } + + /// + /// Length of response APDU. + /// + public ushort ApduLength + { + get + { + return ApduLen; + } + } + + /// + /// Response APDU. + /// + public byte[] ApduResponse + { + get + { + return ApduResp; + } + } + } + + /// + /// A class which defines the response of sending ATR. + /// + public class SimAtrResponse + { + internal ushort AtrRespLen; + internal byte[] AtrResp; + internal SimAtrResponse() + { + } + + /// + /// Length of response ATR. + /// + public ushort AtrRespLength + { + get + { + return AtrRespLen; + } + } + + /// + /// Response ATR. + /// + public byte[] AtrResponse + { + get + { + return AtrResp; + } + } + } + + /// + /// A class which defines ISIM IMPU list data. + /// + public class SimImpuList + { + internal uint DataCount; + internal IEnumerable ImpuList; + internal SimImpuList() + { + } + + /// + /// ISIM IMPU data count. + /// + public uint Count + { + get + { + return DataCount; + } + } + + /// + /// ISIM IMPU list. + /// + public IEnumerable List + { + get + { + return ImpuList; + } + } + } + + /// + /// A class which defines ISIM P-CSCF data. + /// + public class SimPcscf + { + internal SimPcscfType PcscfType; + internal string PcscfData; + internal SimPcscf() + { + } + + /// + /// ISIM P-CSCF type. + /// + public SimPcscfType Type + { + get + { + return PcscfType; + } + } + + /// + /// ISIM P-CSCF data. + /// + public string Pcscf + { + get + { + return PcscfData; + } + } + } + + /// + /// A class which defines ISIM P-CSCF list data. + /// + public class SimPcscfList + { + internal uint DataCount; + internal IEnumerable PcscfList; + internal SimPcscfList() + { + } + + /// + /// ISIM P-CSCF data count. + /// + public uint Count + { + get + { + return DataCount; + } + } + + /// + /// ISIM P-CSCF list. + /// + public IEnumerable List + { + get + { + return PcscfList; + } + } + } +} diff --git a/src/Tizen.Tapi/Tizen.Tapi/SimEnumerations.cs b/src/Tizen.Tapi/Tizen.Tapi/SimEnumerations.cs index 7073957..7c115cd 100755 --- a/src/Tizen.Tapi/Tizen.Tapi/SimEnumerations.cs +++ b/src/Tizen.Tapi/Tizen.Tapi/SimEnumerations.cs @@ -90,7 +90,7 @@ namespace Tizen.Tapi /// /// Enumeration for the SIM card type. /// - public enum SimType + public enum SimCardType { /// /// Unknown card. @@ -422,7 +422,7 @@ namespace Tizen.Tapi } /// - /// Enumeration for the sim number type. + /// Enumeration for the SIM number type. /// public enum SimTypeOfNumber { @@ -506,4 +506,1274 @@ namespace Tizen.Tapi /// ReservedForExt } + + /// + /// Enumeration for the emergency service type. + /// + public enum SimEccEmergencyServiceType + { + /// + /// Police. + /// + Police = 0x01, + /// + /// Ambulance. + /// + Ambulance = 0x02, + /// + /// Fire brigade. + /// + FireBrigade = 0x04, + /// + /// Marine guard. + /// + MarineGuard = 0x08, + /// + /// Mountain rescue. + /// + MountainRescue = 0x10, + /// + /// Spare. + /// + Spare = 0x00 + } + + /// + /// Enumeration for the SIM app type. + /// + public enum SimAppType + { + /// + /// SIM application. + /// + Sim = 0x01, + /// + /// USIM application. + /// + Usim = 0x02, + /// + /// CSIM application. + /// + Csim = 0x04, + /// + /// ISIM application. + /// + Isim = 0x08 + } + + /// + /// Enumeration for the SIM access result from the lower layers. + /// + public enum SimAccessResult + { + /// + /// Access to file is successful. + /// + Success, + /// + /// SIM card error. + /// + CardError, + /// + /// File not found. + /// + FileNotFound, + /// + /// Access condition is not fulfilled. + /// + ConditionNotSatisfied, + /// + /// Access failed. + /// + Failed + } + + /// + /// Enumeration for the mailbox type. + /// + public enum SimMailboxType + { + /// + /// Voicemail. + /// + Voice = 0x01, + /// + /// Fax. + /// + Fax = 0x02, + /// + /// Email. + /// + Email = 0x03, + /// + /// Other. + /// + Other = 0x04, + /// + /// Videomail. + /// + Video = 0x05, + /// + /// Data. + /// + Data = 0x06 + } + + /// + /// Enumeration for the current CPHS phase of the SIM card. + /// + public enum SimCphsPhaseType + { + /// + /// Phase 1. + /// + Phase1 = 0x01, + /// + /// Phase 2. + /// + Phase2 = 0x02, + /// + /// RFU. + /// + Rfu = 0xff + } + + /// + /// Enumeration for CDMA service table. + /// + public enum SimCdmaServiceTable + { + /// + /// CDMA service table. + /// + Cdma = 0, + /// + /// CSIM service table. + /// + Csim, + /// + /// MAX value. + /// + Max + } + + /// + /// Enumeration for the SIM Authentication type. + /// + public enum SimAuthenticationType + { + /// + /// IMS Authentication. + /// + Ims = 0x00, + /// + /// GSM Authentication. + /// + Gsm, + /// + /// 3G Authentication. + /// + Auth3G, + /// + /// CDMA CAVE Authentication. + /// + RuimCave, + /// + /// CDMA CHAP Authentication. + /// + RuimChap, + /// + /// CDMA MNHA Authentication. + /// + RuimMnha, + /// + /// CDMA MIPRRQ Authentication. + /// + RuimMiprrq, + /// + /// CDMA MNAAA Authentication. + /// + RuimMnaaa, + /// + /// CDMA HRPD Authentication. + /// + RuimHrpd, + /// + /// MAX value. + /// + Max + } + + /// + /// Enumeration for the SIM Authentication result. + /// + public enum SimAuthenticationResult + { + /// + /// Status - no error. + /// + NoError = 0x00, + /// + /// Status - can't perform authentication. + /// + CannotPerform, + /// + /// Status - skip authentication response. + /// + SkipResponse, + /// + /// Status - MAK(Multiple Activation Key) code failure. + /// + MakCodeFailure, + /// + /// Status - SQN(SeQuenceNumber) failure. + /// + SqnFailure, + /// + /// Status - synch failure. + /// + SynchFailure, + /// + /// Status - unsupported context. + /// + UnsupportedContext, + /// + /// Status - default error. + /// + Error, + /// + /// MAX value. + /// + Max + } + + /// + /// Enumeration for the PIN type. + /// + public enum SimPinType + { + /// + /// PIN 1 code. + /// + Pin1 = 0x00, + /// + /// PIN 2 code. + /// + Pin2 = 0x01, + /// + /// PUK 1 code. + /// + Puk1 = 0x02, + /// + /// PUK 2 code. + /// + Puk2 = 0x03, + /// + /// Universal PIN - Unused now. + /// + Upin = 0x04, + /// + /// Administrator - Unused now. + /// + Adm = 0x05, + /// + /// SIM Lock code. + /// + Sim = 0x06 + } + + /// + /// Enumeration for the PIN status. + /// + public enum SimFacilityStatus + { + /// + /// Facility disabled. + /// + Disabled = 0x00, + /// + /// Facility enabled. + /// + Enabled = 0x01, + /// + /// Facility unknown. + /// + Unknown = 0xFF + } + + /// + /// Enumeration for the security lock key information. + /// + public enum SimLockStatus + { + /// + /// Key not needed. + /// + NotNeeded = 0x00, + /// + /// PIN required. + /// + Pin = 0x01, + /// + /// PUK required. + /// + Puk = 0x02, + /// + /// PIN2 required. + /// + Pin2 = 0x03, + /// + /// PUK2 required. + /// + Puk2 = 0x04, + /// + /// Permanent block SIM. + /// + PermanentBlocked = 0x05 + } + + /// + /// Enumeration for P-CSCF type. + /// + public enum SimPcscfType + { + /// + /// Fully Qualified Domain Name. + /// + Fqdn, + /// + /// IPv4. + /// + IPv4, + /// + /// IPv6. + /// + IPv6 + } + + /// + /// Enumeration for the SIM power set result from the lower layers. + /// + public enum SimPowerSetResult + { + /// + /// Power Set is successful. + /// + Success, + /// + /// Power Set failure. + /// + Failure + } + + /// + /// Enumeration for the list of IST services in the ISIM Service Table (ISIM). + /// + public enum SimIsimService + { + /// + /// P-CSCF address. + /// + PcscfAddr = 0, + /// + /// Generic Bootstrapping Architecture. + /// + Gba, + /// + /// HTTP Digest. + /// + HttpDigest, + /// + /// GBA-based Local Key Establishment Mechanism. + /// + GbaLocalKey, + /// + /// Support of P-CSCF discovery for IMS Local Break Out. + /// + PcscfLocalBreakOut, + /// + /// Short Message Storage. + /// + Sms, + /// + /// Short Message Status Reports. + /// + Smsr, + /// + /// Support for SM-over-IP including data download via SMS-PP as defined in TS 31.111 [31] + /// + SmOverIP, + /// + /// Communication Control for IMS by ISIM. + /// + CommunicationControl = 8, + /// + /// Support of UICC access to IMS. + /// + AccessToIms, + /// + /// URI support by UICC. + /// + UriSupport + } + + /// + /// Enumeration for the list of SST services in the SIM Service Table (GSM). + /// + public enum SimSstService + { + /// + /// CHV1 disable function. + /// + Chv1DisableFunc = 0, + /// + /// Abbreviated Dialing number. + /// + Adn, + /// + /// Fixed Dialing number. + /// + Fdn, + /// + /// Short message storage. + /// + Sms, + /// + /// Advice of charge. + /// + Aoc, + /// + /// Capability configuration parameters. + /// + Ccp, + /// + /// PLMN selector. + /// + PlmnSelector, + /// + /// RFU. + /// + Rfu1, + /// + /// MSISDN. + /// + Msisdn = 8, + /// + /// Extension 1. + /// + Ext1, + /// + /// Extension 2. + /// + Ext2, + /// + /// SMS parameters. + /// + SmsParams, + /// + /// Last number dialed. + /// + Lnd, + /// + /// Cell broadcast message identifier. + /// + CellBroadcastMsgId, + /// + /// Group identifier level 1. + /// + GidLv1, + /// + /// Group identifier level 2. + /// + GidLv2, + /// + /// Service provider name. + /// + Spn = 16, + /// + /// Service Dialing number. + /// + Sdn, + /// + /// Extension3. + /// + Ext3, + /// + /// RFU. + /// + RFu2, + /// + /// VGCS group identifier (EF-VGCS, EF-VGCSS). + /// + VgcsGidList, + /// + /// VBS group identifier (EF-VBS, EF-VBSS). + /// + VbsGidList, + /// + /// Enhanced multi-level precedence and pre-emption service. + /// + EnhancedMultiLvPrecedencePreemptionSrvc, + /// + /// Automatic answer for EMLPP. + /// + AutoAnswerForEmlpp, + /// + /// Data download via SMS-CB. + /// + DataDownloadViaSmsCb = 24, + /// + /// Data download via SMS-PP. + /// + DataDownloadViaSmsPp, + /// + /// Menu selection. + /// + MenuSelection, + /// + /// Call control. + /// + CallCtrl, + /// + /// Proactive SIM command. + /// + ProactiveSim, + /// + /// Cell broadcast message identifier ranges. + /// + CellBroadcastMsgIdRanges, + /// + /// Barred Dialing numbers. + /// + Bdn, + /// + /// Extension 4. + /// + Ext4, + /// + /// De-personalization control keys. + /// + DepersonalizationCtrlKeys = 32, + /// + /// Co-operative network list. + /// + CooperativeNetworkList, + /// + /// Short message status reports. + /// + SmsStatusReports, + /// + /// Network's indication of alerting in the MS (NIA). + /// + Nia, + /// + /// Mobile-originated short message control by SIM. + /// + MoSmsCtrlBySim, + /// + /// GPRS. + /// + Gprs, + /// + /// Image. + /// + Img, + /// + /// Support of local service area. + /// + Solsa, + /// + /// USSD string data object supported in call control. + /// + UssdStrDataObjectSupportedInCallCtrl = 40, + /// + /// Run at COMMAND command. + /// + RunAtCmdCmd, + /// + /// User controlled PLMN selector with Access technology. + /// + UserCtrledPlmnSelectorWact, + /// + /// Operator controlled PLMN selector with Access technology. + /// + OperatorCtrledPlmnSelectorWact, + /// + /// HPLMN selector with access technology. + /// + HplmnSelectorWact, + /// + /// CPBCCH information. + /// + CpbcchInfo, + /// + /// Investigation scan. + /// + InvestigationScan, + /// + /// Extended capability configuration parameters. + /// + ExtendedCapaConfParams, + /// + /// MExE. + /// + Mexe = 48, + /// + /// RPLMN last used access technology. + /// + RplmnLastUsedAccessTech, + /// + /// PLMN Network Name. + /// + PlmnNetworkName, + /// + /// Operator PLMN List. + /// + OperatorPlmnList, + /// + /// Mailbox Dialling Numbers. + /// + Mbdn, + /// + /// Message Waiting Indication Status. + /// + Mwis, + /// + /// Call Forwarding Indication Status. + /// + Cfis, + /// + /// Service Provider Display Information. + /// + Spdi + } + + /// + /// Enumeration for the list of UST services in the SIM Service Table (USIM). + /// + public enum SimUstService + { + /// + /// Local phone book. + /// + LocalPb = 0, + /// + /// Fixed Dialing number. + /// + Fdn, + /// + /// Extension 2. + /// + Ext2, + /// + /// Service Dialing number. + /// + Sdn, + /// + /// Extension 3. + /// + Ext3, + /// + /// Barred Dialing numbers. + /// + Bdn, + /// + /// Extension 4. + /// + Ext4, + /// + /// Outgoing call information. + /// + OutgoingCallInfo, + /// + /// Incoming call information. + /// + IncomingCallInfo = 8, + /// + /// Short message storage. + /// + Sms, + /// + /// Short message status reports. + /// + SmsStatusReports, + /// + /// SMS parameters. + /// + SmsParams, + /// + /// Advice of charge. + /// + Aoc, + /// + /// Capability configuration parameters. + /// + Ccp, + /// + /// Cell broadcast message identifier. + /// + CellBroadcastMsgId, + /// + /// Cell broadcast message identifier ranges. + /// + CellBroadcastMsgIdRanges, + /// + /// Group identifier level 1. + /// + GidLv1 = 16, + /// + /// Group identifier level 2. + /// + GidLv2, + /// + /// Service provider name. + /// + Spn, + /// + /// User controlled PLMN selector with Access technology. + /// + UserCtrledPlmnSelectorWact, + /// + /// MSISDN. + /// + Msisdn, + /// + /// Image. + /// + Img, + /// + /// Support of local service area. + /// + Solsa, + /// + /// Enhanced multi-level precedence and pre-emption service. + /// + EnhancedMultiLvPrecedencePreemptionSrvc, + /// + /// Automatic answer for EMLPP. + /// + AutoAnswerForEmlpp = 24, + /// + /// RFU. + /// + Rfu1, + /// + /// GSM access. + /// + GsmAccess, + /// + /// Data download via SMS-PP. + /// + DataDownloadViaSmsPp, + /// + /// Data download via SMS-CB. + /// + DataDownloadViaSmsCb, + /// + /// Call control by USIM. + /// + CallCtrl, + /// + /// Mobile-originated short message control by USIM. + /// + MoSmsCtrl, + /// + /// Run at COMMAND command. + /// + RunAtCmdCmd, + /// + /// Shall be set to 1. + /// + ShallBeSetToOne = 32, + /// + /// Enabled service table. + /// + EnabledSrvcTable, + /// + /// APN control list. + /// + Acl, + /// + /// De-personalization control keys. + /// + DepersonalizationCtrlKeys, + /// + /// Co-operative network list. + /// + CooperativeNetworkList, + /// + /// GSM security context. + /// + GsmSecContext, + /// + /// CPBCCH information. + /// + CpbcchInfo, + /// + /// Investigation scan. + /// + InvestigationScan, + /// + /// MExE. + /// + Mexe = 40, + /// + /// Operator controlled PLMN selector with Access technology. + /// + OperatorCtrledPlmnSelectorWact, + /// + /// HPLMN selector with access technology. + /// + HplmnSelectorWact, + /// + /// Extension 5. + /// + Ext5, + /// + /// PLMN Network Name. + /// + PlmnNetworkName, + /// + /// Operator PLMN List. + /// + OperatorPlmnList, + /// + /// Mailbox Dialling Numbers. + /// + Mbdn, + /// + /// Message Waiting Indication Status. + /// + Mwis, + /// + /// Call Forwarding Indication Status. + /// + Cfis = 48, + /// + /// RPLMN last used access technology. + /// + RplmnLastUsedAccessTech, + /// + /// Service Provider Display Information. + /// + Spdi, + /// + /// Multi media messaging service. + /// + Mms, + /// + /// Extension 8. + /// + Ext8, + /// + /// Call control on GPRS by USIM. + /// + CallCtrlOnGprs, + /// + /// MMS user connectivity parameters. + /// + MmsUserConnectivityParams, + /// + /// Network's indication of alerting in the MS (NIA). + /// + Nia, + /// + /// VGCS group identifier List (EF-VGCS, EF-VGCSS). + /// + VgcsGidList = 56, + /// + /// VBS group identifier List (EF-VBS, EF-VBSS). + /// + VbsGidList, + /// + /// Pseudonym. + /// + Pseudonym, + /// + /// User controlled PLMN selector for I-WLAN access. + /// + UserCtrledPlmnSelectorIwlan, + /// + /// Operator controlled PLMN selector for I-WLAN access. + /// + OperatorCtrledPlmnSelectorIwlan, + /// + /// User controlled WSID list. + /// + UserCtrledWsidList, + /// + /// Opertor controlled Wsid list. + /// + OperatorCtrledWsidList, + /// + /// VGCS security. + /// + VgcsSec + } + + /// + /// Enumeration for the list of CST services in the CDMA Service Table. + /// + public enum SimCdmaService + { + /// + /// CHV Disable Option. + /// + ChvDisable = 0, + /// + /// Abbreviated Dialing number. + /// + Adn, + /// + /// Fixed Dialing number. + /// + Fdn, + /// + /// Short message storage. + /// + Sms, + /// + /// HRPD. + /// + Hrpd, + /// + /// Enhanced Phone Book. + /// + Epb, + /// + /// Multimedia domain. + /// + Mmd, + /// + /// SF_EUIMID- based EUIMID. + /// + Euimid, + /// + /// MEID. + /// + Meid = 8, + /// + /// Extension 1. + /// + Ext1, + /// + /// Extension 2. + /// + Ext2, + /// + /// SMS parameters. + /// + Smsp, + /// + /// Last number dialled. + /// + Lnd, + /// + /// Service Category Program for BC-SMS. + /// + Scp, + /// + /// RFU. + /// + Rfu1, + /// + /// RFU. + /// + Rfu2, + /// + /// CDMA Home Service Provider Name. + /// + Hspn = 16, + /// + /// Service Dialing number. + /// + Sdn, + /// + /// Extension 3. + /// + Ext3, + /// + /// 3GPD-SIP. + /// + St3GpdSip, + /// + /// RFU. + /// + Rfu3, + /// + /// RFU. + /// + Rfu4, + /// + /// RFU. + /// + Rfu5, + /// + /// RFU. + /// + Rfu6, + /// + /// Data download by SMS broadcast. + /// + Ddsmsb = 24, + /// + /// Data download by SMS PP. + /// + Ddsmspp, + /// + /// Menu Selection. + /// + Menu, + /// + /// Call Control. + /// + Callc, + /// + /// Proactive RUIM. + /// + Proactive, + /// + /// AKA. + /// + Aka, + /// + /// RFU. + /// + Rfu7, + /// + /// RFU. + /// + Rfu8, + /// + /// RFU. + /// + Rfu9 = 32, + /// + /// RFU. + /// + Rfu10, + /// + /// RFU. + /// + Rfu11, + /// + /// RFU. + /// + Rfu12, + /// + /// RFU. + /// + Rfu13, + /// + /// 3GPD- MIP. + /// + St3GpdMip, + /// + /// BCMCS. + /// + Bcmcs, + /// + /// Multimedia messaging service. + /// + Mms, + /// + /// Extension 8. + /// + Ext8 = 40, + /// + /// MMS User Connectivity Parameters. + /// + Mmsucp, + /// + /// Application Authentication. + /// + Aa, + /// + /// Group Identifier Level 1. + /// + Gil1, + /// + /// Group Identifier Level 2. + /// + Gil2, + /// + /// Depersonalisation control keys. + /// + Deperso, + /// + /// Co-operative Network List. + /// + Cnl + } + + /// + /// Enumeration for the list of CST services in the CSIM Service Table (CSIM). + /// + public enum SimCsimService + { + /// + /// Local Phone book. + /// + LocalPhonebook = 0, + /// + /// Fixed Dialing Numbers (FDN). + /// + Fdn, + /// + /// Extension 2. + /// + Ext2, + /// + /// Service Dialing Numbers (SDN). + /// + Sdn, + /// + /// Extension 3. + /// + Ext3, + /// + /// Short Message Storage (SMS). + /// + Sms, + /// + /// Short Message Parameters. + /// + Smsp, + /// + /// HRPD. + /// + Hrpd, + /// + /// Service Category Program for BC-SMS. + /// + Scp = 8, + /// + /// CDMA Home Service Provider Name. + /// + Hspn, + /// + /// Data Download via SMS Broadcast. + /// + DdSmsb, + /// + /// Data Download via SMS-PP. + /// + DdSmsPp, + /// + /// Call Control. + /// + Callc, + /// + /// 3GPD-SIP. + /// + St3GpdSip, + /// + /// 3GPD-MIP. + /// + St3GpdMip, + /// + /// AKA. + /// + Aka, + /// + /// IP-based Location Services (LCS). + /// + IPLcs = 16, + /// + /// BCMCS. + /// + Bcmcs, + /// + /// Multimedia Messaging Service (MMS). + /// + Mms, + /// + /// Extension 8. + /// + Ext8, + /// + /// MMS User Connectivity Parameters. + /// + Mmsucp, + /// + /// Application Authentication. + /// + Aa, + /// + /// Group Identifier Level 1. + /// + Gil1, + /// + /// Group Identifier Level 2. + /// + Gil2, + /// + /// De-Personalization Control Keys. + /// + Deperso = 24, + /// + /// Cooperative Network List. + /// + Cnl, + /// + /// Outgoing Call Information (OCI). + /// + Oci, + /// + /// Incoming Call Information (ICI). + /// + Ici, + /// + /// Extension 5. + /// + Ext5, + /// + /// Multimedia Storage. + /// + MmStorage, + /// + /// Image (EFIMG). + /// + Img, + /// + /// Enabled Services Table. + /// + Est, + /// + /// Capability Configuration Parameters (CCP). + /// + Ccp = 32, + /// + /// SF_EUIMID-based EUIMID. + /// + Euimidl, + /// + /// Messaging and 3GPD Extensions. + /// + St3GpdExt, + /// + /// Root Certificates. + /// + RootCerti, + /// + /// WAP Browser. + /// + Wap, + /// + /// Java. + /// + Java, + /// + /// Reserved for CDG. + /// + RsvdCdg1, + /// + /// Reserved for CDG. + /// + RsvdCdg2, + /// + /// IPv6. + /// + IPv6 = 40 + } } diff --git a/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs b/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs index 009d41c..0be509a 100755 --- a/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs +++ b/src/Tizen.Tapi/Tizen.Tapi/SimStructs.cs @@ -14,52 +14,1069 @@ * limitations under the License. */ +using System; using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.Text; namespace Tizen.Tapi { [StructLayout(LayoutKind.Sequential)] internal struct SimImsiInfoStruct { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + internal string Mcc; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + internal string Mnc; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)] + internal string Msin; } [StructLayout(LayoutKind.Sequential)] internal struct SimEccInfoStruct { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)] + internal string Name; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)] + internal string Number; + internal SimEccEmergencyServiceType Type; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimEccInfoListStruct + { + internal int Count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15, ArraySubType = UnmanagedType.LPStruct)] + internal SimEccInfoStruct[] ListInfo; + } + + [StructLayout(LayoutKind.Explicit)] + internal struct CfDataStruct + { + [FieldOffset(0)] + internal SimCfisStruct Cfis; + [FieldOffset(0)] + internal SimCphsCfStruct CphsCf; } [StructLayout(LayoutKind.Sequential)] internal struct SimCallForwardRequestStruct { + internal int IsCphs; + internal CfDataStruct CfData; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCfisStruct + { + internal int RecIndex; + internal byte MspNum; + internal byte CfuStatus; + internal SimTypeOfNumber Ton; + internal SimNumberPlanIdentity Npi; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)] + internal string CfuNum; + internal byte Cc2Id; + internal byte Ext7Id; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCfisListStruct + { + internal int ProfileCount; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.LPStruct)] + internal SimCfisStruct[] CfisList; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCphsCfStruct + { + internal int Line1; + internal int Line2; + internal int Fax; + internal int Data; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCallForwardResponseStruct + { + internal int IsCphs; + internal SimCfisListStruct CfList; + internal SimCphsCfStruct CphsCf; + } + + [StructLayout(LayoutKind.Explicit)] + internal struct MwData + { + [FieldOffset(0)] + internal SimMwisStruct Mwis; + [FieldOffset(0)] + internal SimCphsMwStruct CphsMw; } [StructLayout(LayoutKind.Sequential)] internal struct SimMessageWaitingRequestStruct { + internal int IsCphs; + internal MwData Mw; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimMwisStruct + { + internal int RecIndex; + internal byte IndicatorStatus; + internal int VoiceCount; + internal int FaxCount; + internal int EmailCount; + internal int OtherCount; + internal int VideoCount; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimMwisListStruct + { + internal int ProfileCount; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.LPStruct)] + internal SimMwisStruct[] MwList; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCphsMwStruct + { + internal int Voice1; + internal int Voice2; + internal int Fax; + internal int Data; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimMessageWaitingResponseStruct + { + internal int IsCphs; + internal SimMwisListStruct MwList; + internal SimCphsMwStruct CphsMw; } [StructLayout(LayoutKind.Sequential)] internal struct SimMailboxNumberStruct { + internal int IsCphs; + internal int RecIndex; + internal int ProfileNum; + internal SimMailboxType MbType; + internal int AlphaMaxLen; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)] + internal string AlphaId; + internal SimTypeOfNumber Ton; + internal SimNumberPlanIdentity Npi; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)] + internal string Number; + internal byte CcId; + internal byte Ext1Id; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimMailboxListStruct + { + internal int Count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.LPStruct)] + internal SimMailboxNumberStruct[] List; } [StructLayout(LayoutKind.Sequential)] internal struct SimAuthenticationDataStruct { + internal SimAuthenticationType AuthType; + internal int RandLength; + internal int AutnLength; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + internal string RandData; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] + internal string AutnData; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimAuthenticationResponseStruct + { + internal SimAuthenticationType AuthType; + internal SimAuthenticationResult AuthResult; + internal int RespLength; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + internal string RespData; + internal int AuthKeyLength; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + internal string AuthKey; + internal int CipherLength; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + internal string CipherData; + internal int IntegrityLength; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] + internal string IntegrityData; } [StructLayout(LayoutKind.Sequential)] internal struct SimPinDataStruct { + internal SimPinType Type; + [MarshalAs(UnmanagedType.LPStr)] + internal string Pin; + internal uint PinLength; } [StructLayout(LayoutKind.Sequential)] internal struct SimFacilityStruct { + internal SimLockType LockType; + [MarshalAs(UnmanagedType.LPStr)] + internal string Password; + internal int PasswordLength; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimFacilityResultStruct + { + internal SimLockType Type; + internal int RetryCount; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimFacilityInfoStruct + { + internal SimLockType Type; + internal SimFacilityStatus Status; } [StructLayout(LayoutKind.Sequential)] internal struct SimApduStruct { + internal ushort ApduLen; + [MarshalAs(UnmanagedType.LPStr)] + internal string Apdu; + } + [StructLayout(LayoutKind.Sequential)] + internal struct SimApduResponseStruct + { + internal ushort RespLen; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5120)] + internal string ApduResp; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimIccIdInfoStruct + { + internal int IccLength; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)] + internal string IccNumber; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCphsServiceTableStruct + { + internal int CustomerServiceProfile; + internal int ServiceStringTable; + internal int MailboxNumbers; + internal int OperatorNameShortForm; + internal int InformationNumbers; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCphsInfoStruct + { + internal SimCphsPhaseType CphsPhase; + internal SimCphsServiceTableStruct CphsServiceTable; + } + + [StructLayout(LayoutKind.Explicit)] + internal struct CstServiceStrct + { + [FieldOffset(0)] + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 47)] + internal string CdmaService; + [FieldOffset(0)] + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)] + internal string CsimService; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCstStrct + { + internal SimCdmaServiceTable CdmaSvcTable; + internal CstServiceStrct Cst; + } + + [StructLayout(LayoutKind.Explicit)] + internal struct ServiceTable + { + [FieldOffset(0)] + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 56)] + internal string SimSstService; + [FieldOffset(0)] + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] + internal string SimUstService; + [FieldOffset(0)] + internal SimCstStrct Cst; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimServiceTableStruct + { + internal SimCardType SimType; + internal ServiceTable Table; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimSubscriberInfoStruct + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 27)] + internal string Number; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)] + internal string Name; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimMsisdnListStruct + { + internal int Count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3, ArraySubType = UnmanagedType.LPStruct)] + internal SimSubscriberInfoStruct[] List; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimOplmnwactStruct + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)] + internal string Plmn; + internal int IsUmts; + internal int IsGsm; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimOplmnwactListStruct + { + internal int Count; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 100, ArraySubType = UnmanagedType.LPStruct)] + internal SimOplmnwactStruct[] List; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimSpnStruct + { + internal byte DisplayCondition; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)] + internal string Spn; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimCphsNetNameStruct + { + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)] + internal string FullName; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)] + internal string ShortName; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimPinResultStruct + { + internal SimPinType Type; + internal int RetryCount; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimLockInfoStruct + { + internal SimLockType Type; + internal SimLockStatus Status; + internal int RetryCount; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimAtrResponseStruct + { + internal ushort AtrRespLen; + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5120)] + internal string AtrResp; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimImpuListStruct + { + internal uint Count; + internal IntPtr List; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimPcscfStruct + { + internal SimPcscfType Type; + [MarshalAs(UnmanagedType.LPStr)] + internal string Pcscf; + } + + [StructLayout(LayoutKind.Sequential)] + internal struct SimPcscfListStruct + { + internal uint Count; + internal IntPtr List; + } + + internal static class SimStructConversions + { + internal static SimImsiInfo ConvertSimImsiInfoStruct(SimImsiInfoStruct imsiStruct) + { + SimImsiInfo imsi = new SimImsiInfo(); + imsi.CountryCode = imsiStruct.Mcc; + imsi.NetworkCode = imsiStruct.Mnc; + imsi.StationId = imsiStruct.Msin; + return imsi; + } + + internal static SimEccInfo ConvertSimEccInfoStruct(SimEccInfoStruct eccStruct) + { + SimEccInfo ecc = new SimEccInfo(); + ecc.NameInfo = eccStruct.Name; + ecc.NumberInfo = eccStruct.Number; + ecc.TypeInfo = eccStruct.Type; + return ecc; + } + + internal static SimEccInfoList ConvertSimEccInfoListStruct(SimEccInfoListStruct listStruct) + { + SimEccInfoList eccList = new SimEccInfoList(); + eccList.EccCount = listStruct.Count; + List eccInfoList = new List(); + foreach (SimEccInfoStruct info in listStruct.ListInfo) + { + eccInfoList.Add(ConvertSimEccInfoStruct(info)); + } + + eccList.List = eccInfoList; + return eccList; + } + + internal static SimIccIdInfo ConvertSimIccIdInfoStruct(SimIccIdInfoStruct iccStruct) + { + SimIccIdInfo iccId = new SimIccIdInfo(); + iccId.Length = iccStruct.IccLength; + iccId.Number = iccStruct.IccNumber; + return iccId; + } + + internal static SimCfis ConvertSimCfisStruct(SimCfisStruct cfisStruct) + { + SimCfis cfis = new SimCfis(); + cfis.RecIndex = cfisStruct.RecIndex; + cfis.MspNum = cfisStruct.MspNum; + cfis.CfuStatus = cfisStruct.CfuStatus; + cfis.Ton = cfisStruct.Ton; + cfis.Npi = cfisStruct.Npi; + cfis.CfuNum = cfisStruct.CfuNum; + cfis.Cc2Id = cfisStruct.Cc2Id; + cfis.Ext7Id = cfisStruct.Ext7Id; + return cfis; + } + + internal static SimCfisList ConvertSimCfisListStruct(SimCfisListStruct listStruct) + { + SimCfisList cfisList = new SimCfisList(); + cfisList.Count = listStruct.ProfileCount; + List cfis = new List(); + foreach (SimCfisStruct cfStruct in listStruct.CfisList) + { + cfis.Add(ConvertSimCfisStruct(cfStruct)); + } + + cfisList.List = cfis; + return cfisList; + } + + internal static SimCphsCf ConvertSimCphsCfStruct(SimCphsCfStruct cphsCfStruct) + { + SimCphsCf cphs = new SimCphsCf(); + cphs.Line1 = cphsCfStruct.Line1; + cphs.Line2 = cphsCfStruct.Line2; + cphs.Fax = cphsCfStruct.Fax; + cphs.Data = cphsCfStruct.Data; + return cphs; + } + + internal static SimCallForwardResponse ConvertSimCallForwardResponseStruct(SimCallForwardResponseStruct respStruct) + { + SimCallForwardResponse resp = new SimCallForwardResponse(); + if (respStruct.IsCphs == 1) + { + resp.IsCphsCf = true; + } + + else if (respStruct.IsCphs == 0) + { + resp.IsCphsCf = false; + } + + resp.List = ConvertSimCfisListStruct(respStruct.CfList); + resp.CphsCfInfo = ConvertSimCphsCfStruct(respStruct.CphsCf); + return resp; + } + + internal static SimMwis ConvertSimMwisStruct(SimMwisStruct mwisStruct) + { + SimMwis mwis = new SimMwis(); + mwis.RecIndex = mwisStruct.RecIndex; + mwis.IndicatorStatus = mwisStruct.IndicatorStatus; + mwis.VoiceCount = mwisStruct.VoiceCount; + mwis.FaxCount = mwisStruct.FaxCount; + mwis.EmailCount = mwisStruct.EmailCount; + mwis.OtherCount = mwisStruct.OtherCount; + mwis.VideoCount = mwisStruct.VideoCount; + return mwis; + } + + internal static SimMwisList ConvertSimMwisListStruct(SimMwisListStruct mwStruct) + { + SimMwisList mwList = new SimMwisList(); + mwList.Count = mwStruct.ProfileCount; + List mwisList = new List(); + foreach (SimMwisStruct mwisStruct in mwStruct.MwList) + { + mwisList.Add(ConvertSimMwisStruct(mwisStruct)); + } + + mwList.List = mwisList; + return mwList; + } + + internal static SimCphsMw ConvertSimCphsMwStruct(SimCphsMwStruct cphsStruct) + { + SimCphsMw cphsMw = new SimCphsMw(); + if (cphsStruct.Voice1 == 1) + { + cphsMw.IsVoice1 = true; + } + + else + { + cphsMw.IsVoice1 = false; + } + + if (cphsStruct.Voice2 == 1) + { + cphsMw.IsVoice2 = true; + } + + else + { + cphsMw.IsVoice2 = false; + } + + if (cphsStruct.Fax == 1) + { + cphsMw.IsFax = true; + } + + else + { + cphsMw.IsFax = false; + } + + if (cphsStruct.Data == 1) + { + cphsMw.IsData = true; + } + + else + { + cphsMw.IsData = false; + } + + return cphsMw; + } + + internal static SimMessageWaitingResponse ConvertSimMessageWaitingRespStruct(SimMessageWaitingResponseStruct responseStruct) + { + SimMessageWaitingResponse waitingResp = new SimMessageWaitingResponse(); + if (responseStruct.IsCphs == 1) + { + waitingResp.IsCphsMw = true; + } + + else + { + waitingResp.IsCphsMw = false; + } + + waitingResp.List = ConvertSimMwisListStruct(responseStruct.MwList); + waitingResp.CphsMwInfo = ConvertSimCphsMwStruct(responseStruct.CphsMw); + return waitingResp; + } + + internal static SimMailboxNumber ConvertSimMailboxNumberStruct(SimMailboxNumberStruct mbStruct) + { + SimMailboxNumber mbNumber = new SimMailboxNumber(); + if (mbStruct.IsCphs == 1) + { + mbNumber.IsCphs = true; + } + + else if (mbStruct.IsCphs == 0) + { + mbNumber.IsCphs = false; + } + + mbNumber.RecIndex = mbStruct.RecIndex; + mbNumber.ProfileNumber = mbStruct.ProfileNum; + mbNumber.MbType = mbStruct.MbType; + mbNumber.AlphaMaxLength = mbStruct.AlphaMaxLen; + mbNumber.AlphaId = mbStruct.AlphaId; + mbNumber.Ton = mbStruct.Ton; + mbNumber.Npi = mbStruct.Npi; + mbNumber.Number = mbStruct.Number; + mbNumber.CcId = mbStruct.CcId; + mbNumber.Ext1Id = mbStruct.Ext1Id; + return mbNumber; + } + + internal static SimMailboxList ConvertSimMailboxListStruct(SimMailboxListStruct mbListStruct) + { + SimMailboxList mbList = new SimMailboxList(); + mbList.MbCount = mbListStruct.Count; + List mbNumList = new List(); + foreach (SimMailboxNumberStruct mbStruct in mbListStruct.List) + { + mbNumList.Add(ConvertSimMailboxNumberStruct(mbStruct)); + } + + mbList.MbList = mbNumList; + return mbList; + } + + internal static SimCphsServiceTable ConvertSimCphsServiceTableStruct(SimCphsServiceTableStruct svcStruct) + { + SimCphsServiceTable svcTable = new SimCphsServiceTable(); + svcTable.CustomerSvcProfile = svcStruct.CustomerServiceProfile; + svcTable.SvcStringTable = svcStruct.ServiceStringTable; + svcTable.MbNumbers = svcStruct.MailboxNumbers; + svcTable.OperatorNameShort = svcStruct.OperatorNameShortForm; + svcTable.InformationNum = svcStruct.InformationNumbers; + return svcTable; + } + + internal static SimCphsInfo ConvertSimCphsInfoStruct(SimCphsInfoStruct cphsStruct) + { + SimCphsInfo cphsInfo = new SimCphsInfo(); + cphsInfo.Phase = cphsStruct.CphsPhase; + cphsInfo.CphsSvcTable = ConvertSimCphsServiceTableStruct(cphsStruct.CphsServiceTable); + return cphsInfo; + } + + internal static SimCst ConvertSimCstStruct(SimCstStrct cstStruct) + { + SimCst cst = new SimCst(); + cst.CdmaSvc = cstStruct.CdmaSvcTable; + if (cstStruct.CdmaSvcTable == SimCdmaServiceTable.Cdma) + { + cst.Cdma = Encoding.ASCII.GetBytes(cstStruct.Cst.CdmaService); + } + + else if (cstStruct.CdmaSvcTable == SimCdmaServiceTable.Csim) + { + cst.Csim = Encoding.ASCII.GetBytes(cstStruct.Cst.CsimService); + } + + return cst; + } + + internal static SimServiceTable ConvertSimServiceTableStruct(SimServiceTableStruct svcTableStruct) + { + SimServiceTable svcTable = new SimServiceTable(); + svcTable.Type = svcTableStruct.SimType; + if (svcTableStruct.SimType == SimCardType.Gsm) + { + svcTable.Sst = Encoding.ASCII.GetBytes(svcTableStruct.Table.SimSstService); + } + + else if (svcTableStruct.SimType == SimCardType.Usim) + { + svcTable.Ust = Encoding.ASCII.GetBytes(svcTableStruct.Table.SimUstService); + } + + else if (svcTableStruct.SimType == SimCardType.Ruim) + { + svcTable.Cst = ConvertSimCstStruct(svcTableStruct.Table.Cst); + } + + return svcTable; + } + + internal static SimSubscriberInfo ConvertSimSubscriberInfoStruct(SimSubscriberInfoStruct infoStruct) + { + SimSubscriberInfo subscriber = new SimSubscriberInfo(); + subscriber.MsisdnNum = infoStruct.Number; + subscriber.MsisdnName = infoStruct.Name; + return subscriber; + } + + internal static SimMsisdnList ConvertSimMsisdnListStruct(SimMsisdnListStruct msisdnStruct) + { + SimMsisdnList list = new SimMsisdnList(); + list.MsisdnCount = msisdnStruct.Count; + List subsList = new List(); + foreach (SimSubscriberInfoStruct subsStruct in msisdnStruct.List) + { + subsList.Add(ConvertSimSubscriberInfoStruct(subsStruct)); + } + + list.SubscriberList = subsList; + return list; + } + + internal static SimOplmnwact ConvertSimOplmnwactStruct(SimOplmnwactStruct oplmnStruct) + { + SimOplmnwact oplmn = new SimOplmnwact(); + oplmn.PlmnString = oplmnStruct.Plmn; + if (oplmnStruct.IsUmts == 1) + { + oplmn.UmtsFlag = true; + } + + else if (oplmnStruct.IsUmts == 0) + { + oplmn.UmtsFlag = false; + } + + if (oplmnStruct.IsGsm == 1) + { + oplmn.GsmFlag = true; + } + + else if (oplmnStruct.IsGsm == 0) + { + oplmn.GsmFlag = false; + } + + return oplmn; + } + + internal static SimOplmnwactList ConvertSimOplmnwactListStruct(SimOplmnwactListStruct listStruct) + { + SimOplmnwactList oplmnList = new SimOplmnwactList(); + oplmnList.OplmnCount = listStruct.Count; + List wactList = new List(); + foreach (SimOplmnwactStruct wactStruct in listStruct.List) + { + wactList.Add(ConvertSimOplmnwactStruct(wactStruct)); + } + + oplmnList.OplmnList = wactList; + return oplmnList; + } + + internal static SimSpn ConvertSimSpnStruct(SimSpnStruct spnStruct) + { + SimSpn spn = new SimSpn(); + spn.Condition = spnStruct.DisplayCondition; + spn.SpName = spnStruct.Spn; + return spn; + } + + internal static SimCphsNetName ConvertSimCphsNetNameStruct(SimCphsNetNameStruct cphsStruct) + { + SimCphsNetName cphsName = new SimCphsNetName(); + cphsName.Full = cphsStruct.FullName; + cphsName.Short = cphsStruct.ShortName; + return cphsName; + } + + internal static SimAuthenticationResponse ConvertSimAuthenticationResponseStruct(SimAuthenticationResponseStruct respStruct) + { + SimAuthenticationResponse response = new SimAuthenticationResponse(); + response.Type = respStruct.AuthType; + response.Result = respStruct.AuthResult; + response.RespLength = respStruct.RespLength; + response.RespData = respStruct.RespData; + response.AuthKeyLen = respStruct.AuthKeyLength; + response.Key = respStruct.AuthKey; + response.CipherLen = respStruct.CipherLength; + response.Cipher = respStruct.CipherData; + response.IntegrityLen = respStruct.IntegrityLength; + response.Integrity = respStruct.IntegrityData; + return response; + } + + internal static SimPinResult ConvertSimPinResultStruct(SimPinResultStruct resultStruct) + { + SimPinResult pinResult = new SimPinResult(); + pinResult.PinType = resultStruct.Type; + pinResult.Retry = resultStruct.RetryCount; + return pinResult; + } + + internal static SimFacilityResult ConvertSimFacilityResultStruct(SimFacilityResultStruct resultStruct) + { + SimFacilityResult facilityResult = new SimFacilityResult(); + facilityResult.LockType = resultStruct.Type; + facilityResult.Count = resultStruct.RetryCount; + return facilityResult; + } + + internal static SimFacilityInfo ConvertSimFacilityInfoStruct(SimFacilityInfoStruct infoStruct) + { + SimFacilityInfo facilityInfo = new SimFacilityInfo(); + facilityInfo.LockType = infoStruct.Type; + facilityInfo.FacilityStatus = infoStruct.Status; + return facilityInfo; + } + + internal static SimLockInfo ConvertSimLockInfoStruct(SimLockInfoStruct infoStruct) + { + SimLockInfo lockInfo = new SimLockInfo(); + lockInfo.LockType = infoStruct.Type; + lockInfo.LockStatus = infoStruct.Status; + lockInfo.Count = infoStruct.RetryCount; + return lockInfo; + } + + internal static SimApduResponse ConvertSimApduResponseStruct(SimApduResponseStruct respStruct) + { + SimApduResponse response = new SimApduResponse(); + response.ApduLen = respStruct.RespLen; + response.ApduResp = Encoding.ASCII.GetBytes(respStruct.ApduResp); + return response; + } + + internal static SimAtrResponse ConvertSimAtrResponseStruct(SimAtrResponseStruct respStruct) + { + SimAtrResponse atrResp = new SimAtrResponse(); + atrResp.AtrRespLen = respStruct.AtrRespLen; + atrResp.AtrResp = Encoding.ASCII.GetBytes(respStruct.AtrResp); + return atrResp; + } + + internal static SimImpuList ConvertSimImpuListStruct(SimImpuListStruct listStruct) + { + SimImpuList impuList = new SimImpuList(); + impuList.DataCount = listStruct.Count; + IntPtr[] ptrList = new IntPtr[listStruct.Count]; + Marshal.Copy(listStruct.List, ptrList, 0, (int)listStruct.Count); + List list = new List(); + for (int i = 0; i < listStruct.Count; i++) + { + list.Add(Marshal.PtrToStringAnsi(ptrList[i])); + } + + impuList.ImpuList = list; + return impuList; + } + + internal static SimPcscf ConvertSimPcscfStruct(SimPcscfStruct pcscfStruct) + { + SimPcscf pcscf = new SimPcscf(); + pcscf.PcscfType = pcscfStruct.Type; + pcscf.PcscfData = pcscfStruct.Pcscf; + return pcscf; + } + + internal static SimPcscfList ConvertSimPcscfListStruct(SimPcscfListStruct listStruct) + { + SimPcscfList pcscfList = new SimPcscfList(); + pcscfList.DataCount = listStruct.Count; + IntPtr[] ptrList = new IntPtr[listStruct.Count]; + Marshal.Copy(listStruct.List, ptrList, 0, (int)listStruct.Count); + List list = new List(); + for (int i = 0; i < listStruct.Count; i++) + { + list.Add(ConvertSimPcscfStruct(Marshal.PtrToStructure(ptrList[i]))); + } + + pcscfList.PcscfList = list; + return pcscfList; + } + } + + internal static class SimClassConversions + { + internal static SimCallForwardRequestStruct ConvertSimCallForwardRequest(SimCallForwardRequest request) + { + SimCallForwardRequestStruct cfStruct = new SimCallForwardRequestStruct(); + if (request.IsCphs == true) + { + cfStruct.IsCphs = 1; + } + + else if (request.IsCphs == false) + { + cfStruct.IsCphs = 0; + } + + if (request.IsCphs == true) + { + cfStruct.CfData.CphsCf.Line1 = request.CphsCf.Line1; + cfStruct.CfData.CphsCf.Line2 = request.CphsCf.Line2; + cfStruct.CfData.CphsCf.Fax = request.CphsCf.Fax; + cfStruct.CfData.CphsCf.Data = request.CphsCf.Data; + } + + else + { + cfStruct.CfData.Cfis.RecIndex = request.Cfis.RecIndex; + cfStruct.CfData.Cfis.MspNum = request.Cfis.MspNum; + cfStruct.CfData.Cfis.CfuStatus = request.Cfis.CfuStatus; + cfStruct.CfData.Cfis.Ton = request.Cfis.Ton; + cfStruct.CfData.Cfis.Npi = request.Cfis.Npi; + cfStruct.CfData.Cfis.CfuNum = request.Cfis.CfuNum; + cfStruct.CfData.Cfis.Cc2Id = request.Cfis.Cc2Id; + cfStruct.CfData.Cfis.Ext7Id = request.Cfis.Ext7Id; + } + + return cfStruct; + } + + internal static SimMwisStruct ConvertSimMwis(SimMwis mwis) + { + SimMwisStruct mwisStruct = new SimMwisStruct(); + mwisStruct.RecIndex = mwis.RecIndex; + mwisStruct.IndicatorStatus = mwis.IndicatorStatus; + mwisStruct.VoiceCount = mwis.VoiceCount; + mwisStruct.FaxCount = mwis.FaxCount; + mwisStruct.EmailCount = mwis.EmailCount; + mwisStruct.OtherCount = mwis.OtherCount; + mwisStruct.VideoCount = mwis.VideoCount; + return mwisStruct; + } + + internal static SimCphsMwStruct ConvertSimCphsMw(SimCphsMw cphsMw) + { + SimCphsMwStruct cphsStruct = new SimCphsMwStruct(); + if (cphsMw.IsVoice1 == true) + { + cphsStruct.Voice1 = 1; + } + + else + { + cphsStruct.Voice1 = 0; + } + + if (cphsMw.IsVoice2 == true) + { + cphsStruct.Voice2 = 1; + } + + else + { + cphsStruct.Voice2 = 0; + } + + if (cphsMw.IsFax == true) + { + cphsStruct.Fax = 1; + } + + else + { + cphsStruct.Fax = 0; + } + + if (cphsMw.IsData == true) + { + cphsStruct.Data = 1; + } + + else + { + cphsStruct.Data = 0; + } + + return cphsStruct; + } + + internal static SimMessageWaitingRequestStruct ConvertSimMessageWaitingRequest(SimMessageWaitingRequest request) + { + SimMessageWaitingRequestStruct requestStruct = new SimMessageWaitingRequestStruct(); + if (request.IsCphs == true) + { + requestStruct.IsCphs = 1; + } + + else + { + requestStruct.IsCphs = 0; + } + + if (request.IsCphs == true) + { + requestStruct.Mw.CphsMw = ConvertSimCphsMw(request.CphsMw); + } + + else + { + requestStruct.Mw.Mwis = ConvertSimMwis(request.Mwis); + } + + return requestStruct; + } + + internal static SimMailboxNumberStruct ConvertSimMailboxNumber(SimMailboxNumber mbNumber) + { + SimMailboxNumberStruct mbStruct = new SimMailboxNumberStruct(); + if (mbNumber.IsCphs) + { + mbStruct.IsCphs = 1; + } + + else + { + mbStruct.IsCphs = 0; + } + + mbStruct.RecIndex = mbNumber.RecIndex; + mbStruct.ProfileNum = mbNumber.ProfileNumber; + mbStruct.MbType = mbNumber.MbType; + mbStruct.AlphaMaxLen = mbNumber.AlphaMaxLength; + mbStruct.AlphaId = mbNumber.AlphaId; + mbStruct.Ton = mbNumber.Ton; + mbStruct.Npi = mbNumber.Npi; + mbStruct.Number = mbNumber.Number; + mbStruct.CcId = mbNumber.CcId; + mbStruct.Ext1Id = mbNumber.Ext1Id; + return mbStruct; + } + + internal static SimPinDataStruct ConvertSimPinData(SimPinData data) + { + SimPinDataStruct pinStruct = new SimPinDataStruct(); + pinStruct.Type = data.Type; + pinStruct.Pin = data.Pin; + pinStruct.PinLength = data.PinLength; + return pinStruct; + } + + internal static SimFacilityStruct ConvertSimFacility(SimFacility facility) + { + SimFacilityStruct facilityStruct = new SimFacilityStruct(); + facilityStruct.LockType = facility.LockType; + facilityStruct.Password = facility.Password; + facilityStruct.PasswordLength = facility.PasswordLength; + return facilityStruct; + } + + internal static SimApduStruct ConvertSimApdu(SimApdu apdu) + { + SimApduStruct apduStruct = new SimApduStruct(); + apduStruct.ApduLen = apdu.ApduLength; + apduStruct.Apdu = Encoding.UTF8.GetString(apdu.Apdu); + return apduStruct; + } + + internal static SimAuthenticationDataStruct ConvertSimAuthenticationDataStruct(SimAuthenticationData authData) + { + SimAuthenticationDataStruct authStruct = new SimAuthenticationDataStruct(); + authStruct.AuthType = authData.AuthType; + authStruct.RandLength = authData.RandLength; + authStruct.AutnLength = authData.AutnLength; + authStruct.RandData = Encoding.UTF8.GetString(authData.RandData); + authStruct.AutnData = Encoding.UTF8.GetString(authData.AutnData); + return authStruct; + } } }