2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using System.Collections.Generic;
24 [StructLayout(LayoutKind.Sequential)]
25 internal struct SimImsiInfoStruct
27 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
29 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
31 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
35 [StructLayout(LayoutKind.Sequential)]
36 internal struct SimEccInfoStruct
38 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
40 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)]
41 internal string Number;
42 internal SimEccEmergencyServiceType Type;
45 [StructLayout(LayoutKind.Sequential)]
46 internal struct SimEccInfoListStruct
49 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15, ArraySubType = UnmanagedType.LPStruct)]
50 internal SimEccInfoStruct[] ListInfo;
53 [StructLayout(LayoutKind.Explicit)]
54 internal struct CfDataStruct
57 internal SimCfisStruct Cfis;
59 internal SimCphsCfStruct CphsCf;
62 [StructLayout(LayoutKind.Sequential)]
63 internal struct SimCallForwardRequestStruct
66 internal CfDataStruct CfData;
69 [StructLayout(LayoutKind.Sequential)]
70 internal struct SimCfisStruct
72 internal int RecIndex;
74 internal byte CfuStatus;
75 internal SimTypeOfNumber Ton;
76 internal SimNumberPlanIdentity Npi;
77 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
78 internal string CfuNum;
83 [StructLayout(LayoutKind.Sequential)]
84 internal struct SimCfisListStruct
86 internal int ProfileCount;
87 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.LPStruct)]
88 internal SimCfisStruct[] CfisList;
91 [StructLayout(LayoutKind.Sequential)]
92 internal struct SimCphsCfStruct
100 [StructLayout(LayoutKind.Sequential)]
101 internal struct SimCallForwardResponseStruct
104 internal SimCfisListStruct CfList;
105 internal SimCphsCfStruct CphsCf;
108 [StructLayout(LayoutKind.Explicit)]
109 internal struct MwData
112 internal SimMwisStruct Mwis;
114 internal SimCphsMwStruct CphsMw;
117 [StructLayout(LayoutKind.Sequential)]
118 internal struct SimMessageWaitingRequestStruct
124 [StructLayout(LayoutKind.Sequential)]
125 internal struct SimMwisStruct
127 internal int RecIndex;
128 internal byte IndicatorStatus;
129 internal int VoiceCount;
130 internal int FaxCount;
131 internal int EmailCount;
132 internal int OtherCount;
133 internal int VideoCount;
136 [StructLayout(LayoutKind.Sequential)]
137 internal struct SimMwisListStruct
139 internal int ProfileCount;
140 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.LPStruct)]
141 internal SimMwisStruct[] MwList;
144 [StructLayout(LayoutKind.Sequential)]
145 internal struct SimCphsMwStruct
153 [StructLayout(LayoutKind.Sequential)]
154 internal struct SimMessageWaitingResponseStruct
157 internal SimMwisListStruct MwList;
158 internal SimCphsMwStruct CphsMw;
161 [StructLayout(LayoutKind.Sequential)]
162 internal struct SimMailboxNumberStruct
165 internal int RecIndex;
166 internal int ProfileNum;
167 internal SimMailboxType MbType;
168 internal int AlphaMaxLen;
169 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
170 internal string AlphaId;
171 internal SimTypeOfNumber Ton;
172 internal SimNumberPlanIdentity Npi;
173 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
174 internal string Number;
176 internal byte Ext1Id;
179 [StructLayout(LayoutKind.Sequential)]
180 internal struct SimMailboxListStruct
183 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.LPStruct)]
184 internal SimMailboxNumberStruct[] List;
187 [StructLayout(LayoutKind.Sequential)]
188 internal struct SimAuthenticationDataStruct
190 internal SimAuthenticationType AuthType;
191 internal int RandLength;
192 internal int AutnLength;
193 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
194 internal string RandData;
195 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
196 internal string AutnData;
199 [StructLayout(LayoutKind.Sequential)]
200 internal struct SimAuthenticationResponseStruct
202 internal SimAuthenticationType AuthType;
203 internal SimAuthenticationResult AuthResult;
204 internal int RespLength;
205 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
206 internal string RespData;
207 internal int AuthKeyLength;
208 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
209 internal string AuthKey;
210 internal int CipherLength;
211 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
212 internal string CipherData;
213 internal int IntegrityLength;
214 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
215 internal string IntegrityData;
218 [StructLayout(LayoutKind.Sequential)]
219 internal struct SimPinDataStruct
221 internal SimPinType Type;
222 [MarshalAs(UnmanagedType.LPStr)]
224 internal uint PinLength;
227 [StructLayout(LayoutKind.Sequential)]
228 internal struct SimFacilityStruct
230 internal SimLockType LockType;
231 [MarshalAs(UnmanagedType.LPStr)]
232 internal string Password;
233 internal int PasswordLength;
236 [StructLayout(LayoutKind.Sequential)]
237 internal struct SimFacilityResultStruct
239 internal SimLockType Type;
240 internal int RetryCount;
243 [StructLayout(LayoutKind.Sequential)]
244 internal struct SimFacilityInfoStruct
246 internal SimLockType Type;
247 internal SimFacilityStatus Status;
250 [StructLayout(LayoutKind.Sequential)]
251 internal struct SimApduStruct
253 internal ushort ApduLen;
254 [MarshalAs(UnmanagedType.LPStr)]
255 internal string Apdu;
257 [StructLayout(LayoutKind.Sequential)]
258 internal struct SimApduResponseStruct
260 internal ushort RespLen;
261 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5120)]
262 internal string ApduResp;
265 [StructLayout(LayoutKind.Sequential)]
266 internal struct SimIccIdInfoStruct
268 internal int IccLength;
269 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
270 internal string IccNumber;
273 [StructLayout(LayoutKind.Sequential)]
274 internal struct SimCphsServiceTableStruct
276 internal int CustomerServiceProfile;
277 internal int ServiceStringTable;
278 internal int MailboxNumbers;
279 internal int OperatorNameShortForm;
280 internal int InformationNumbers;
283 [StructLayout(LayoutKind.Sequential)]
284 internal struct SimCphsInfoStruct
286 internal SimCphsPhaseType CphsPhase;
287 internal SimCphsServiceTableStruct CphsServiceTable;
290 [StructLayout(LayoutKind.Explicit)]
291 internal struct CstServiceStrct
294 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 47)]
295 internal string CdmaService;
297 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)]
298 internal string CsimService;
301 [StructLayout(LayoutKind.Sequential)]
302 internal struct SimCstStrct
304 internal SimCdmaServiceTable CdmaSvcTable;
305 internal CstServiceStrct Cst;
308 [StructLayout(LayoutKind.Explicit)]
309 internal struct ServiceTable
312 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 56)]
313 internal string SimSstService;
315 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
316 internal string SimUstService;
318 internal SimCstStrct Cst;
321 [StructLayout(LayoutKind.Sequential)]
322 internal struct SimServiceTableStruct
324 internal SimCardType SimType;
325 internal ServiceTable Table;
328 [StructLayout(LayoutKind.Sequential)]
329 internal struct SimSubscriberInfoStruct
331 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 27)]
332 internal string Number;
333 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
334 internal string Name;
337 [StructLayout(LayoutKind.Sequential)]
338 internal struct SimMsisdnListStruct
341 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3, ArraySubType = UnmanagedType.LPStruct)]
342 internal SimSubscriberInfoStruct[] List;
345 [StructLayout(LayoutKind.Sequential)]
346 internal struct SimOplmnwactStruct
348 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)]
349 internal string Plmn;
354 [StructLayout(LayoutKind.Sequential)]
355 internal struct SimOplmnwactListStruct
358 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 100, ArraySubType = UnmanagedType.LPStruct)]
359 internal SimOplmnwactStruct[] List;
362 [StructLayout(LayoutKind.Sequential)]
363 internal struct SimSpnStruct
365 internal byte DisplayCondition;
366 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)]
370 [StructLayout(LayoutKind.Sequential)]
371 internal struct SimCphsNetNameStruct
373 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)]
374 internal string FullName;
375 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
376 internal string ShortName;
379 [StructLayout(LayoutKind.Sequential)]
380 internal struct SimPinResultStruct
382 internal SimPinType Type;
383 internal int RetryCount;
386 [StructLayout(LayoutKind.Sequential)]
387 internal struct SimLockInfoStruct
389 internal SimLockType Type;
390 internal SimLockStatus Status;
391 internal int RetryCount;
394 [StructLayout(LayoutKind.Sequential)]
395 internal struct SimAtrResponseStruct
397 internal ushort AtrRespLen;
398 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 5120)]
399 internal string AtrResp;
402 [StructLayout(LayoutKind.Sequential)]
403 internal struct SimImpuListStruct
406 internal IntPtr List;
409 [StructLayout(LayoutKind.Sequential)]
410 internal struct SimPcscfStruct
412 internal SimPcscfType Type;
413 [MarshalAs(UnmanagedType.LPStr)]
414 internal string Pcscf;
417 [StructLayout(LayoutKind.Sequential)]
418 internal struct SimPcscfListStruct
421 internal IntPtr List;
424 internal static class SimStructConversions
426 internal static SimImsiInfo ConvertSimImsiInfoStruct(SimImsiInfoStruct imsiStruct)
428 SimImsiInfo imsi = new SimImsiInfo();
429 imsi.CountryCode = imsiStruct.Mcc;
430 imsi.NetworkCode = imsiStruct.Mnc;
431 imsi.StationId = imsiStruct.Msin;
435 internal static SimEccInfo ConvertSimEccInfoStruct(SimEccInfoStruct eccStruct)
437 SimEccInfo ecc = new SimEccInfo();
438 ecc.NameInfo = eccStruct.Name;
439 ecc.NumberInfo = eccStruct.Number;
440 ecc.TypeInfo = eccStruct.Type;
444 internal static SimEccInfoList ConvertSimEccInfoListStruct(SimEccInfoListStruct listStruct)
446 SimEccInfoList eccList = new SimEccInfoList();
447 eccList.EccCount = listStruct.Count;
448 List<SimEccInfo> eccInfoList = new List<SimEccInfo>();
449 foreach (SimEccInfoStruct info in listStruct.ListInfo)
451 eccInfoList.Add(ConvertSimEccInfoStruct(info));
454 eccList.List = eccInfoList;
458 internal static SimIccIdInfo ConvertSimIccIdInfoStruct(SimIccIdInfoStruct iccStruct)
460 SimIccIdInfo iccId = new SimIccIdInfo();
461 iccId.Length = iccStruct.IccLength;
462 iccId.Number = iccStruct.IccNumber;
466 internal static SimCfis ConvertSimCfisStruct(SimCfisStruct cfisStruct)
468 SimCfis cfis = new SimCfis();
469 cfis.RecIndex = cfisStruct.RecIndex;
470 cfis.MspNum = cfisStruct.MspNum;
471 cfis.CfuStatus = cfisStruct.CfuStatus;
472 cfis.Ton = cfisStruct.Ton;
473 cfis.Npi = cfisStruct.Npi;
474 cfis.CfuNum = cfisStruct.CfuNum;
475 cfis.Cc2Id = cfisStruct.Cc2Id;
476 cfis.Ext7Id = cfisStruct.Ext7Id;
480 internal static SimCfisList ConvertSimCfisListStruct(SimCfisListStruct listStruct)
482 SimCfisList cfisList = new SimCfisList();
483 cfisList.Count = listStruct.ProfileCount;
484 List<SimCfis> cfis = new List<SimCfis>();
485 foreach (SimCfisStruct cfStruct in listStruct.CfisList)
487 cfis.Add(ConvertSimCfisStruct(cfStruct));
490 cfisList.List = cfis;
494 internal static SimCphsCf ConvertSimCphsCfStruct(SimCphsCfStruct cphsCfStruct)
496 SimCphsCf cphs = new SimCphsCf();
497 cphs.Line1 = cphsCfStruct.Line1;
498 cphs.Line2 = cphsCfStruct.Line2;
499 cphs.Fax = cphsCfStruct.Fax;
500 cphs.Data = cphsCfStruct.Data;
504 internal static SimCallForwardResponse ConvertSimCallForwardResponseStruct(SimCallForwardResponseStruct respStruct)
506 SimCallForwardResponse resp = new SimCallForwardResponse();
507 if (respStruct.IsCphs == 1)
509 resp.IsCphsCf = true;
512 else if (respStruct.IsCphs == 0)
514 resp.IsCphsCf = false;
517 resp.List = ConvertSimCfisListStruct(respStruct.CfList);
518 resp.CphsCfInfo = ConvertSimCphsCfStruct(respStruct.CphsCf);
522 internal static SimMwis ConvertSimMwisStruct(SimMwisStruct mwisStruct)
524 SimMwis mwis = new SimMwis();
525 mwis.RecIndex = mwisStruct.RecIndex;
526 mwis.IndicatorStatus = mwisStruct.IndicatorStatus;
527 mwis.VoiceCount = mwisStruct.VoiceCount;
528 mwis.FaxCount = mwisStruct.FaxCount;
529 mwis.EmailCount = mwisStruct.EmailCount;
530 mwis.OtherCount = mwisStruct.OtherCount;
531 mwis.VideoCount = mwisStruct.VideoCount;
535 internal static SimMwisList ConvertSimMwisListStruct(SimMwisListStruct mwStruct)
537 SimMwisList mwList = new SimMwisList();
538 mwList.Count = mwStruct.ProfileCount;
539 List<SimMwis> mwisList = new List<SimMwis>();
540 foreach (SimMwisStruct mwisStruct in mwStruct.MwList)
542 mwisList.Add(ConvertSimMwisStruct(mwisStruct));
545 mwList.List = mwisList;
549 internal static SimCphsMw ConvertSimCphsMwStruct(SimCphsMwStruct cphsStruct)
551 SimCphsMw cphsMw = new SimCphsMw();
552 if (cphsStruct.Voice1 == 1)
554 cphsMw.IsVoice1 = true;
559 cphsMw.IsVoice1 = false;
562 if (cphsStruct.Voice2 == 1)
564 cphsMw.IsVoice2 = true;
569 cphsMw.IsVoice2 = false;
572 if (cphsStruct.Fax == 1)
579 cphsMw.IsFax = false;
582 if (cphsStruct.Data == 1)
584 cphsMw.IsData = true;
589 cphsMw.IsData = false;
595 internal static SimMessageWaitingResponse ConvertSimMessageWaitingRespStruct(SimMessageWaitingResponseStruct responseStruct)
597 SimMessageWaitingResponse waitingResp = new SimMessageWaitingResponse();
598 if (responseStruct.IsCphs == 1)
600 waitingResp.IsCphsMw = true;
605 waitingResp.IsCphsMw = false;
608 waitingResp.List = ConvertSimMwisListStruct(responseStruct.MwList);
609 waitingResp.CphsMwInfo = ConvertSimCphsMwStruct(responseStruct.CphsMw);
613 internal static SimMailboxNumber ConvertSimMailboxNumberStruct(SimMailboxNumberStruct mbStruct)
615 SimMailboxNumber mbNumber = new SimMailboxNumber();
616 if (mbStruct.IsCphs == 1)
618 mbNumber.IsCphs = true;
621 else if (mbStruct.IsCphs == 0)
623 mbNumber.IsCphs = false;
626 mbNumber.RecIndex = mbStruct.RecIndex;
627 mbNumber.ProfileNumber = mbStruct.ProfileNum;
628 mbNumber.MbType = mbStruct.MbType;
629 mbNumber.AlphaMaxLength = mbStruct.AlphaMaxLen;
630 mbNumber.AlphaId = mbStruct.AlphaId;
631 mbNumber.Ton = mbStruct.Ton;
632 mbNumber.Npi = mbStruct.Npi;
633 mbNumber.Number = mbStruct.Number;
634 mbNumber.CcId = mbStruct.CcId;
635 mbNumber.Ext1Id = mbStruct.Ext1Id;
639 internal static SimMailboxList ConvertSimMailboxListStruct(SimMailboxListStruct mbListStruct)
641 SimMailboxList mbList = new SimMailboxList();
642 mbList.MbCount = mbListStruct.Count;
643 List<SimMailboxNumber> mbNumList = new List<SimMailboxNumber>();
644 foreach (SimMailboxNumberStruct mbStruct in mbListStruct.List)
646 mbNumList.Add(ConvertSimMailboxNumberStruct(mbStruct));
649 mbList.MbList = mbNumList;
653 internal static SimCphsServiceTable ConvertSimCphsServiceTableStruct(SimCphsServiceTableStruct svcStruct)
655 SimCphsServiceTable svcTable = new SimCphsServiceTable();
656 svcTable.CustomerSvcProfile = svcStruct.CustomerServiceProfile;
657 svcTable.SvcStringTable = svcStruct.ServiceStringTable;
658 svcTable.MbNumbers = svcStruct.MailboxNumbers;
659 svcTable.OperatorNameShort = svcStruct.OperatorNameShortForm;
660 svcTable.InformationNum = svcStruct.InformationNumbers;
664 internal static SimCphsInfo ConvertSimCphsInfoStruct(SimCphsInfoStruct cphsStruct)
666 SimCphsInfo cphsInfo = new SimCphsInfo();
667 cphsInfo.Phase = cphsStruct.CphsPhase;
668 cphsInfo.CphsSvcTable = ConvertSimCphsServiceTableStruct(cphsStruct.CphsServiceTable);
672 internal static SimCst ConvertSimCstStruct(SimCstStrct cstStruct)
674 SimCst cst = new SimCst();
675 cst.CdmaSvc = cstStruct.CdmaSvcTable;
676 if (cstStruct.CdmaSvcTable == SimCdmaServiceTable.Cdma)
678 cst.Cdma = Encoding.ASCII.GetBytes(cstStruct.Cst.CdmaService);
681 else if (cstStruct.CdmaSvcTable == SimCdmaServiceTable.Csim)
683 cst.Csim = Encoding.ASCII.GetBytes(cstStruct.Cst.CsimService);
689 internal static SimServiceTable ConvertSimServiceTableStruct(SimServiceTableStruct svcTableStruct)
691 SimServiceTable svcTable = new SimServiceTable();
692 svcTable.Type = svcTableStruct.SimType;
693 if (svcTableStruct.SimType == SimCardType.Gsm)
695 svcTable.Sst = Encoding.ASCII.GetBytes(svcTableStruct.Table.SimSstService);
698 else if (svcTableStruct.SimType == SimCardType.Usim)
700 svcTable.Ust = Encoding.ASCII.GetBytes(svcTableStruct.Table.SimUstService);
703 else if (svcTableStruct.SimType == SimCardType.Ruim)
705 svcTable.Cst = ConvertSimCstStruct(svcTableStruct.Table.Cst);
711 internal static SimSubscriberInfo ConvertSimSubscriberInfoStruct(SimSubscriberInfoStruct infoStruct)
713 SimSubscriberInfo subscriber = new SimSubscriberInfo();
714 subscriber.MsisdnNum = infoStruct.Number;
715 subscriber.MsisdnName = infoStruct.Name;
719 internal static SimMsisdnList ConvertSimMsisdnListStruct(SimMsisdnListStruct msisdnStruct)
721 SimMsisdnList list = new SimMsisdnList();
722 list.MsisdnCount = msisdnStruct.Count;
723 List<SimSubscriberInfo> subsList = new List<SimSubscriberInfo>();
724 foreach (SimSubscriberInfoStruct subsStruct in msisdnStruct.List)
726 subsList.Add(ConvertSimSubscriberInfoStruct(subsStruct));
729 list.SubscriberList = subsList;
733 internal static SimOplmnwact ConvertSimOplmnwactStruct(SimOplmnwactStruct oplmnStruct)
735 SimOplmnwact oplmn = new SimOplmnwact();
736 oplmn.PlmnString = oplmnStruct.Plmn;
737 if (oplmnStruct.IsUmts == 1)
739 oplmn.UmtsFlag = true;
742 else if (oplmnStruct.IsUmts == 0)
744 oplmn.UmtsFlag = false;
747 if (oplmnStruct.IsGsm == 1)
749 oplmn.GsmFlag = true;
752 else if (oplmnStruct.IsGsm == 0)
754 oplmn.GsmFlag = false;
760 internal static SimOplmnwactList ConvertSimOplmnwactListStruct(SimOplmnwactListStruct listStruct)
762 SimOplmnwactList oplmnList = new SimOplmnwactList();
763 oplmnList.OplmnCount = listStruct.Count;
764 List<SimOplmnwact> wactList = new List<SimOplmnwact>();
765 foreach (SimOplmnwactStruct wactStruct in listStruct.List)
767 wactList.Add(ConvertSimOplmnwactStruct(wactStruct));
770 oplmnList.OplmnList = wactList;
774 internal static SimSpn ConvertSimSpnStruct(SimSpnStruct spnStruct)
776 SimSpn spn = new SimSpn();
777 spn.Condition = spnStruct.DisplayCondition;
778 spn.SpName = spnStruct.Spn;
782 internal static SimCphsNetName ConvertSimCphsNetNameStruct(SimCphsNetNameStruct cphsStruct)
784 SimCphsNetName cphsName = new SimCphsNetName();
785 cphsName.Full = cphsStruct.FullName;
786 cphsName.Short = cphsStruct.ShortName;
790 internal static SimAuthenticationResponse ConvertSimAuthenticationResponseStruct(SimAuthenticationResponseStruct respStruct)
792 SimAuthenticationResponse response = new SimAuthenticationResponse();
793 response.Type = respStruct.AuthType;
794 response.Result = respStruct.AuthResult;
795 response.RespLength = respStruct.RespLength;
796 response.RespData = respStruct.RespData;
797 response.AuthKeyLen = respStruct.AuthKeyLength;
798 response.Key = respStruct.AuthKey;
799 response.CipherLen = respStruct.CipherLength;
800 response.Cipher = respStruct.CipherData;
801 response.IntegrityLen = respStruct.IntegrityLength;
802 response.Integrity = respStruct.IntegrityData;
806 internal static SimPinResult ConvertSimPinResultStruct(SimPinResultStruct resultStruct)
808 SimPinResult pinResult = new SimPinResult();
809 pinResult.PinType = resultStruct.Type;
810 pinResult.Retry = resultStruct.RetryCount;
814 internal static SimFacilityResult ConvertSimFacilityResultStruct(SimFacilityResultStruct resultStruct)
816 SimFacilityResult facilityResult = new SimFacilityResult();
817 facilityResult.LockType = resultStruct.Type;
818 facilityResult.Count = resultStruct.RetryCount;
819 return facilityResult;
822 internal static SimFacilityInfo ConvertSimFacilityInfoStruct(SimFacilityInfoStruct infoStruct)
824 SimFacilityInfo facilityInfo = new SimFacilityInfo();
825 facilityInfo.LockType = infoStruct.Type;
826 facilityInfo.FacilityStatus = infoStruct.Status;
830 internal static SimLockInfo ConvertSimLockInfoStruct(SimLockInfoStruct infoStruct)
832 SimLockInfo lockInfo = new SimLockInfo();
833 lockInfo.LockType = infoStruct.Type;
834 lockInfo.LockStatus = infoStruct.Status;
835 lockInfo.Count = infoStruct.RetryCount;
839 internal static SimApduResponse ConvertSimApduResponseStruct(SimApduResponseStruct respStruct)
841 SimApduResponse response = new SimApduResponse();
842 response.ApduLen = respStruct.RespLen;
843 response.ApduResp = Encoding.ASCII.GetBytes(respStruct.ApduResp);
847 internal static SimAtrResponse ConvertSimAtrResponseStruct(SimAtrResponseStruct respStruct)
849 SimAtrResponse atrResp = new SimAtrResponse();
850 atrResp.AtrRespLen = respStruct.AtrRespLen;
851 atrResp.AtrResp = Encoding.ASCII.GetBytes(respStruct.AtrResp);
855 internal static SimImpuList ConvertSimImpuListStruct(SimImpuListStruct listStruct)
857 SimImpuList impuList = new SimImpuList();
858 impuList.DataCount = listStruct.Count;
859 IntPtr[] ptrList = new IntPtr[listStruct.Count];
860 Marshal.Copy(listStruct.List, ptrList, 0, (int)listStruct.Count);
861 List<string> list = new List<string>();
862 for (int i = 0; i < listStruct.Count; i++)
864 list.Add(Marshal.PtrToStringAnsi(ptrList[i]));
867 impuList.ImpuList = list;
871 internal static SimPcscf ConvertSimPcscfStruct(SimPcscfStruct pcscfStruct)
873 SimPcscf pcscf = new SimPcscf();
874 pcscf.PcscfType = pcscfStruct.Type;
875 pcscf.PcscfData = pcscfStruct.Pcscf;
879 internal static SimPcscfList ConvertSimPcscfListStruct(SimPcscfListStruct listStruct)
881 SimPcscfList pcscfList = new SimPcscfList();
882 pcscfList.DataCount = listStruct.Count;
883 IntPtr[] ptrList = new IntPtr[listStruct.Count];
884 Marshal.Copy(listStruct.List, ptrList, 0, (int)listStruct.Count);
885 List<SimPcscf> list = new List<SimPcscf>();
886 for (int i = 0; i < listStruct.Count; i++)
888 list.Add(ConvertSimPcscfStruct(Marshal.PtrToStructure<SimPcscfStruct>(ptrList[i])));
891 pcscfList.PcscfList = list;
896 internal static class SimClassConversions
898 internal static SimCallForwardRequestStruct ConvertSimCallForwardRequest(SimCallForwardRequest request)
900 SimCallForwardRequestStruct cfStruct = new SimCallForwardRequestStruct();
901 if (request.IsCphs == true)
906 else if (request.IsCphs == false)
911 if (request.IsCphs == true)
913 cfStruct.CfData.CphsCf.Line1 = request.CphsCf.Line1;
914 cfStruct.CfData.CphsCf.Line2 = request.CphsCf.Line2;
915 cfStruct.CfData.CphsCf.Fax = request.CphsCf.Fax;
916 cfStruct.CfData.CphsCf.Data = request.CphsCf.Data;
921 cfStruct.CfData.Cfis.RecIndex = request.Cfis.RecIndex;
922 cfStruct.CfData.Cfis.MspNum = request.Cfis.MspNum;
923 cfStruct.CfData.Cfis.CfuStatus = request.Cfis.CfuStatus;
924 cfStruct.CfData.Cfis.Ton = request.Cfis.Ton;
925 cfStruct.CfData.Cfis.Npi = request.Cfis.Npi;
926 cfStruct.CfData.Cfis.CfuNum = request.Cfis.CfuNum;
927 cfStruct.CfData.Cfis.Cc2Id = request.Cfis.Cc2Id;
928 cfStruct.CfData.Cfis.Ext7Id = request.Cfis.Ext7Id;
934 internal static SimMwisStruct ConvertSimMwis(SimMwis mwis)
936 SimMwisStruct mwisStruct = new SimMwisStruct();
937 mwisStruct.RecIndex = mwis.RecIndex;
938 mwisStruct.IndicatorStatus = mwis.IndicatorStatus;
939 mwisStruct.VoiceCount = mwis.VoiceCount;
940 mwisStruct.FaxCount = mwis.FaxCount;
941 mwisStruct.EmailCount = mwis.EmailCount;
942 mwisStruct.OtherCount = mwis.OtherCount;
943 mwisStruct.VideoCount = mwis.VideoCount;
947 internal static SimCphsMwStruct ConvertSimCphsMw(SimCphsMw cphsMw)
949 SimCphsMwStruct cphsStruct = new SimCphsMwStruct();
950 if (cphsMw.IsVoice1 == true)
952 cphsStruct.Voice1 = 1;
957 cphsStruct.Voice1 = 0;
960 if (cphsMw.IsVoice2 == true)
962 cphsStruct.Voice2 = 1;
967 cphsStruct.Voice2 = 0;
970 if (cphsMw.IsFax == true)
980 if (cphsMw.IsData == true)
993 internal static SimMessageWaitingRequestStruct ConvertSimMessageWaitingRequest(SimMessageWaitingRequest request)
995 SimMessageWaitingRequestStruct requestStruct = new SimMessageWaitingRequestStruct();
996 if (request.IsCphs == true)
998 requestStruct.IsCphs = 1;
1003 requestStruct.IsCphs = 0;
1006 if (request.IsCphs == true)
1008 requestStruct.Mw.CphsMw = ConvertSimCphsMw(request.CphsMw);
1013 requestStruct.Mw.Mwis = ConvertSimMwis(request.Mwis);
1016 return requestStruct;
1019 internal static SimMailboxNumberStruct ConvertSimMailboxNumber(SimMailboxNumber mbNumber)
1021 SimMailboxNumberStruct mbStruct = new SimMailboxNumberStruct();
1022 if (mbNumber.IsCphs)
1024 mbStruct.IsCphs = 1;
1029 mbStruct.IsCphs = 0;
1032 mbStruct.RecIndex = mbNumber.RecIndex;
1033 mbStruct.ProfileNum = mbNumber.ProfileNumber;
1034 mbStruct.MbType = mbNumber.MbType;
1035 mbStruct.AlphaMaxLen = mbNumber.AlphaMaxLength;
1036 mbStruct.AlphaId = mbNumber.AlphaId;
1037 mbStruct.Ton = mbNumber.Ton;
1038 mbStruct.Npi = mbNumber.Npi;
1039 mbStruct.Number = mbNumber.Number;
1040 mbStruct.CcId = mbNumber.CcId;
1041 mbStruct.Ext1Id = mbNumber.Ext1Id;
1045 internal static SimPinDataStruct ConvertSimPinData(SimPinData data)
1047 SimPinDataStruct pinStruct = new SimPinDataStruct();
1048 pinStruct.Type = data.Type;
1049 pinStruct.Pin = data.Pin;
1050 pinStruct.PinLength = data.PinLength;
1054 internal static SimFacilityStruct ConvertSimFacility(SimFacility facility)
1056 SimFacilityStruct facilityStruct = new SimFacilityStruct();
1057 facilityStruct.LockType = facility.LockType;
1058 facilityStruct.Password = facility.Password;
1059 facilityStruct.PasswordLength = facility.PasswordLength;
1060 return facilityStruct;
1063 internal static SimApduStruct ConvertSimApdu(SimApdu apdu)
1065 SimApduStruct apduStruct = new SimApduStruct();
1066 apduStruct.ApduLen = apdu.ApduLength;
1067 apduStruct.Apdu = Encoding.UTF8.GetString(apdu.Apdu);
1071 internal static SimAuthenticationDataStruct ConvertSimAuthenticationDataStruct(SimAuthenticationData authData)
1073 SimAuthenticationDataStruct authStruct = new SimAuthenticationDataStruct();
1074 authStruct.AuthType = authData.AuthType;
1075 authStruct.RandLength = authData.RandLength;
1076 authStruct.AutnLength = authData.AutnLength;
1077 authStruct.RandData = Encoding.UTF8.GetString(authData.RandData);
1078 authStruct.AutnData = Encoding.UTF8.GetString(authData.AutnData);