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.
17 using System.Runtime.InteropServices;
19 using System.Collections.Generic;
23 [StructLayout(LayoutKind.Sequential)]
24 internal struct PhonebookRecordStruct
26 internal PhonebookType Type;
27 internal ushort Index;
28 internal ushort NextIndex;
29 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
31 internal TextEncryptionType Dcs;
32 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
33 internal string Number;
34 internal SimTypeOfNumber Ton;
35 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
37 internal TextEncryptionType SneDcs;
38 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
40 internal SimTypeOfNumber Anr1Ton;
41 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
43 internal SimTypeOfNumber Anr2Ton;
44 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
46 internal SimTypeOfNumber Anr3Ton;
47 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
48 internal string Email1;
49 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
50 internal string Email2;
51 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
52 internal string Email3;
53 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
54 internal string Email4;
55 internal ushort GroupIndex;
56 internal ushort PbControl;
59 [StructLayout(LayoutKind.Sequential)]
60 internal struct SimPhonebookListStruct
70 [StructLayout(LayoutKind.Sequential)]
71 internal struct SimPhonebookStatusStruct
73 internal int IsInitCompleted;
74 internal SimPhonebookListStruct PbList;
77 [StructLayout(LayoutKind.Sequential)]
78 internal struct PhonebookContactChangeInfoStruct
80 internal PhonebookType Type;
81 internal ushort Index;
82 internal PhonebookOperationType Operation;
85 [StructLayout(LayoutKind.Sequential)]
86 internal struct PhonebookStorageInfoStruct
88 internal PhonebookType Type;
89 internal ushort TotalRecord;
90 internal ushort UsedRecord;
93 [StructLayout(LayoutKind.Sequential)]
94 internal struct PhonebookMetaInfoStruct
96 internal PhonebookType Type;
97 internal ushort MinIndex;
98 internal ushort MaxIndex;
99 internal ushort NumMaxLength;
100 internal ushort TextMaxLength;
101 internal ushort UsedCount;
104 [StructLayout(LayoutKind.Sequential)]
105 internal struct FileTypeCapabilityInfo3GStruct
107 internal PhonebookFileType3G FileType;
108 internal ushort MaxIndex;
109 internal ushort MaxTextLen;
110 internal ushort UsedCount;
113 [StructLayout(LayoutKind.Sequential)]
114 internal struct PhonebookMetaInfo3GStruct
116 internal ushort FileTypeCount;
117 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13, ArraySubType = UnmanagedType.LPStruct)]
118 internal FileTypeCapabilityInfo3GStruct[] FileTypeInfo;
121 internal static class PhonebookStructConversions
123 internal static SimPhonebookList ConvertSimPhonebookListStruct(SimPhonebookListStruct listStruct)
125 SimPhonebookList list = new SimPhonebookList();
126 list.PbFdn = listStruct.Fdn;
127 list.PbAdn = listStruct.Adn;
128 list.PbSdn = listStruct.Sdn;
129 list.PbUsim = listStruct.Usim;
130 list.PbAas = listStruct.Aas;
131 list.PbGas = listStruct.Gas;
135 internal static SimPhonebookStatus ConvertSimPhonebookStatusStruct(SimPhonebookStatusStruct statusStruct)
137 SimPhonebookStatus status = new SimPhonebookStatus();
138 if (statusStruct.IsInitCompleted == 1)
140 status.InitStatus = true;
143 else if (statusStruct.IsInitCompleted == 0)
145 status.InitStatus = false;
148 status.List = ConvertSimPhonebookListStruct(statusStruct.PbList);
152 internal static PhonebookStorageInfo ConvertPhonebookStorageStruct(PhonebookStorageInfoStruct storageStruct)
154 PhonebookStorageInfo storageInfo = new PhonebookStorageInfo();
155 storageInfo.PbType = storageStruct.Type;
156 storageInfo.PbTotalRecord = storageStruct.TotalRecord;
157 storageInfo.PbUsedRecord = storageStruct.UsedRecord;
161 internal static PhonebookMetaInfo ConvertPhonebookMetaInfoStruct(PhonebookMetaInfoStruct metaStruct)
163 PhonebookMetaInfo info = new PhonebookMetaInfo();
164 info.MetaType = metaStruct.Type;
165 info.MinIdx = metaStruct.MinIndex;
166 info.MaxIdx = metaStruct.MaxIndex;
167 info.NumMaxLength = metaStruct.NumMaxLength;
168 info.TextMaxLen = metaStruct.TextMaxLength;
169 info.UsedRecCount = metaStruct.UsedCount;
173 internal static FileTypeCapabilityInfo3G ConvertFileTypeCapabilityInfo3GStruct(FileTypeCapabilityInfo3GStruct infoStruct)
175 FileTypeCapabilityInfo3G info = new FileTypeCapabilityInfo3G();
176 info.Type = infoStruct.FileType;
177 info.MaxIdx = infoStruct.MaxIndex;
178 info.TextMaxLen = infoStruct.MaxTextLen;
179 info.UsedRecCount = infoStruct.UsedCount;
183 internal static PhonebookMetaInfo3G ConvertPhonebookMetaInfo3GStruct(PhonebookMetaInfo3GStruct infoStruct)
185 PhonebookMetaInfo3G info = new PhonebookMetaInfo3G();
186 info.FileCount = infoStruct.FileTypeCount;
187 List<FileTypeCapabilityInfo3G> capabilityList = new List<FileTypeCapabilityInfo3G>();
188 foreach (FileTypeCapabilityInfo3GStruct capabilityInfo in infoStruct.FileTypeInfo)
190 capabilityList.Add(ConvertFileTypeCapabilityInfo3GStruct(capabilityInfo));
193 info.FileInfo = capabilityList;
197 internal static PhonebookContactChangeInfo ConvertPhonebookContactChangeStruct(PhonebookContactChangeInfoStruct infoStruct)
199 PhonebookContactChangeInfo info = new PhonebookContactChangeInfo();
200 info.PbType = infoStruct.Type;
201 info.ChangedIndex = infoStruct.Index;
202 info.OpType = infoStruct.Operation;
206 internal static PhonebookRecord ConvertPhonebookRecordStruct(PhonebookRecordStruct recordStruct)
208 PhonebookRecord record = new PhonebookRecord();
209 record.Type = recordStruct.Type;
210 record.Index = recordStruct.Index;
211 record.NextIndex = recordStruct.NextIndex;
212 record.Name = recordStruct.Name;
213 record.Dcs = recordStruct.Dcs;
214 record.Number = recordStruct.Number;
215 record.Ton = recordStruct.Ton;
216 record.Sne = recordStruct.Sne;
217 record.SneDcs = recordStruct.SneDcs;
218 record.Anr1 = recordStruct.Anr1;
219 record.Anr1Ton = recordStruct.Anr1Ton;
220 record.Anr2 = recordStruct.Anr2;
221 record.Anr2Ton = recordStruct.Anr2Ton;
222 record.Anr3 = recordStruct.Anr3;
223 record.Anr3Ton = recordStruct.Anr3Ton;
224 record.Email1 = recordStruct.Email1;
225 record.Email2 = recordStruct.Email2;
226 record.Email3 = recordStruct.Email3;
227 record.Email4 = recordStruct.Email4;
228 record.GroupIndex = recordStruct.GroupIndex;
229 record.PbControl = recordStruct.PbControl;
234 internal static class PhonebookClassConversions
236 internal static PhonebookRecordStruct ConvertPhonebookrecord(PhonebookRecord record)
238 PhonebookRecordStruct recordStruct = new PhonebookRecordStruct();
239 recordStruct.Type = record.Type;
240 recordStruct.Index = record.Index;
241 recordStruct.NextIndex = record.NextIndex;
242 recordStruct.Name = record.Name;
243 recordStruct.Dcs = record.Dcs;
244 recordStruct.Number = record.Number;
245 recordStruct.Ton = record.Ton;
246 recordStruct.Sne = record.Sne;
247 recordStruct.SneDcs = record.SneDcs;
248 recordStruct.Anr1 = record.Anr1;
249 recordStruct.Anr1Ton = record.Anr1Ton;
250 recordStruct.Anr2 = record.Anr2;
251 recordStruct.Anr2Ton = record.Anr2Ton;
252 recordStruct.Anr3 = record.Anr3;
253 recordStruct.Anr3Ton = record.Anr3Ton;
254 recordStruct.Email1 = record.Email1;
255 recordStruct.Email2 = record.Email2;
256 recordStruct.Email3 = record.Email3;
257 recordStruct.Email4 = record.Email4;
258 recordStruct.GroupIndex = record.GroupIndex;
259 recordStruct.PbControl = record.PbControl;