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.Collections.Generic;
19 using System.Runtime.InteropServices;
23 [StructLayout(LayoutKind.Sequential)]
24 internal struct CallIdleStatusNotiStruct
27 internal CallEndCause Cause;
30 [StructLayout(LayoutKind.Sequential)]
31 internal struct CallIncomingInfoStruct
34 internal CallType Type;
35 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TapiUtility.CallDialNumberMaxLen)]
36 internal string CallerNumber;
37 internal CallerName NameData;
38 internal CallCliMode CliMode;
39 internal CallNoCliCause CliCause;
40 internal int IsForwarded;
41 internal CallActiveLine ActiveLine;
44 [StructLayout(LayoutKind.Sequential)]
45 internal struct CallerName
47 internal CallNameMode NameMode;
48 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TapiUtility.CallNameMaxSize)]
52 [StructLayout(LayoutKind.Sequential)]
53 internal struct CallRecordLineControlStruct
55 internal byte PolarityIncluded;
56 internal byte ToggleMode;
57 internal byte ReversePolarity;
58 internal byte PowerDenialTime;
61 [StructLayout(LayoutKind.Explicit)]
62 internal struct CallRecordDataStruct
64 [MarshalAs(UnmanagedType.LPStr)]
67 [MarshalAs(UnmanagedType.LPStr)]
69 internal IntPtr Number;
71 internal CallRecordLineControlStruct LineCtrl;
74 [StructLayout(LayoutKind.Sequential)]
75 internal struct CallRecordStruct
78 internal CallRecordType Type;
79 internal CallRecordDataStruct Data;
82 [StructLayout(LayoutKind.Explicit)]
83 internal struct CallSignalStruct
86 internal CallToneSignal SignalTone;
88 internal CallIsdnAlertSignal IsdnAlert;
90 internal CallIs54bAlertSignal Is54bAlert;
93 [StructLayout(LayoutKind.Sequential)]
94 internal struct CallSignalInfoStruct
96 internal CallAlertSignal SignalType;
97 internal CallAlertPitch PitchType;
98 internal CallSignalStruct CallSignal;
101 [StructLayout(LayoutKind.Sequential)]
102 internal struct CallInformationStruct
104 internal CallType Type;
105 internal EmergencyType EType;
106 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TapiUtility.CallDialNumberMaxLen)]
107 internal string PhoneNumber;
110 [StructLayout(LayoutKind.Sequential)]
111 internal struct CallBurstDtmfStruct
113 [MarshalAs(UnmanagedType.LPStr)]
114 internal string Dtmf;
115 internal CallDtmfPulseWidth Width;
116 internal CallDtmfDigitInterval Interval;
119 [StructLayout(LayoutKind.Sequential)]
120 internal struct CallStatusStruct
122 internal int CallHandle;
123 internal int BMoCall;
124 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = TapiUtility.CallDialNumberMaxLen)]
125 internal string PhoneNumber;
126 internal CallType Type;
127 internal CallState State;
128 internal int BConferenceState;
129 internal int BVolteCall;
132 [StructLayout(LayoutKind.Sequential)]
133 internal struct CallDeflectDestStruct
135 internal IntPtr DestinationNumber;
138 [StructLayout(LayoutKind.Sequential)]
139 internal struct CallVolumeRecordStruct
141 internal SoundDevice Device;
142 internal SoundType Type;
143 internal SoundVolume Volume;
146 [StructLayout(LayoutKind.Sequential)]
147 internal struct CallSoundPathStruct
149 internal SoundPath Path;
150 internal ExtraVolume ExVolume;
153 [StructLayout(LayoutKind.Sequential)]
154 internal struct CallUpgradeDowngradeNotiStruct
156 internal int CallHandle;
157 internal CallConfigType ConfigType;
160 [StructLayout(LayoutKind.Sequential)]
161 internal struct CallOperationsStruct
166 [StructLayout(LayoutKind.Sequential)]
167 internal struct CallEndStruct
169 internal CallEndType type;
173 [StructLayout(LayoutKind.Sequential)]
174 internal struct CallVolumeStruct
176 internal uint number;
177 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20, ArraySubType = UnmanagedType.LPStruct)]
178 internal CallVolumeRecordStruct[] recordList;
181 [StructLayout(LayoutKind.Sequential)]
182 internal struct CallMuteStatusStruct
184 internal SoundMutePath Path;
185 internal SoundMuteStatus Status;
188 [StructLayout(LayoutKind.Sequential)]
189 internal struct CallPrivacyModeStruct
191 internal CallPrivacyMode Mode;
194 internal static class CallStructConversions
196 internal static CallIdleStatusNotificationData ConvertCallIdleStatusNoti(CallIdleStatusNotiStruct idleStatusNoti)
198 CallIdleStatusNotificationData idleStatusNotiData = new CallIdleStatusNotificationData();
199 idleStatusNotiData.Id = idleStatusNoti.Id;
200 idleStatusNotiData.Cause = idleStatusNoti.Cause;
201 return idleStatusNotiData;
204 internal static CallIncomingInfo ConvertIncomingCallInfo(CallIncomingInfoStruct incomingInfo)
206 CallIncomingInfo callIncoming = new CallIncomingInfo();
207 callIncoming.Handle = incomingInfo.Handle;
208 callIncoming.Type = incomingInfo.Type;
209 callIncoming.Number = incomingInfo.CallerNumber;
210 CallerNameInfo nameData = new CallerNameInfo();
211 nameData.Mode = incomingInfo.NameData.NameMode;
212 nameData.NameData = incomingInfo.NameData.Name;
214 callIncoming.Name = nameData;
215 callIncoming.Cli = incomingInfo.CliMode;
216 callIncoming.Cause = incomingInfo.CliCause;
217 if (incomingInfo.IsForwarded == 1)
219 callIncoming.IsFwded = true;
222 else if (incomingInfo.IsForwarded == 0)
224 callIncoming.IsFwded = false;
227 callIncoming.Line = incomingInfo.ActiveLine;
232 internal static CallRecord ConvertCallRecordStruct(CallRecordStruct record)
234 CallRecord recordData = new CallRecord();
235 recordData.Id = record.Id;
236 recordData.Type = record.Type;
237 if (record.Type == CallRecordType.Name)
239 recordData.Name = Marshal.PtrToStringAnsi(record.Data.Name);
242 else if (record.Type == CallRecordType.Number)
244 recordData.Number = Marshal.PtrToStringAnsi(record.Data.Number);
247 else if (record.Type == CallRecordType.LineControl)
249 CallRecordLineControl lineCtrl = new CallRecordLineControl();
250 lineCtrl.PolarityInc = record.Data.LineCtrl.PolarityIncluded;
251 lineCtrl.Toggle = record.Data.LineCtrl.ToggleMode;
252 lineCtrl.ReversePol = record.Data.LineCtrl.ReversePolarity;
253 lineCtrl.PowerTime = record.Data.LineCtrl.PowerDenialTime;
254 recordData.LineCtrl = lineCtrl;
260 internal static CallSignalNotification ConvertCallSignalInfo(CallSignalInfoStruct signalInfo)
262 CallSignalNotification signalNoti = new CallSignalNotification();
263 signalNoti.Signal = signalInfo.SignalType;
264 signalNoti.Pitch = signalInfo.PitchType;
265 if (signalInfo.SignalType == CallAlertSignal.Tone)
267 signalNoti.Tone = signalInfo.CallSignal.SignalTone;
270 else if (signalInfo.SignalType == CallAlertSignal.IsdnAlert)
272 signalNoti.Isdn = signalInfo.CallSignal.IsdnAlert;
275 else if (signalInfo.SignalType == CallAlertSignal.Is54bAlert)
277 signalNoti.Is54b = signalInfo.CallSignal.Is54bAlert;
283 internal static CallUpgradeDowngradeRequestNoti ConvertCallUpgradeNoti(CallUpgradeDowngradeNotiStruct notiStruct)
285 CallUpgradeDowngradeRequestNoti requestNoti = new CallUpgradeDowngradeRequestNoti();
286 requestNoti.Handle = notiStruct.CallHandle;
287 requestNoti.Type = notiStruct.ConfigType;
291 internal static CallStatus ConvertStatusStruct(CallStatusStruct statusStruct)
293 CallStatus statusData = new CallStatus();
294 statusData.CallHandle = statusStruct.CallHandle;
295 statusData.IsMoCall = Convert.ToBoolean(statusStruct.BMoCall);
296 statusData.PhoneNumber = statusStruct.PhoneNumber;
297 statusData.Type = statusStruct.Type;
298 statusData.State = statusStruct.State;
299 statusData.IsConferenceState = Convert.ToBoolean(statusStruct.BConferenceState);
300 statusData.IsVolteCall = Convert.ToBoolean(statusStruct.BVolteCall);
304 internal static CallVolumeInfo ConvertVolumeStruct(CallVolumeStruct volumeStruct)
306 List<CallVolumeRecord> records = new List<CallVolumeRecord>();
307 foreach(CallVolumeRecordStruct record in volumeStruct.recordList)
309 records.Add(new CallVolumeRecord(record.Device, record.Type, record.Volume));
312 CallVolumeInfo volumeInfo = new CallVolumeInfo(volumeStruct.number, records);
317 internal static class CallClassConversions
319 internal static CallInformationStruct ConvertCallInformationToStruct(CallInformation info)
321 CallInformationStruct callInfoStruct = new CallInformationStruct();
322 callInfoStruct.Type = info.Type;
323 callInfoStruct.EType = info.EType;
324 callInfoStruct.PhoneNumber = info.PhoneNumber;
325 return callInfoStruct;
328 internal static CallBurstDtmfStruct ConvertCallBurstToStruct(CallBurstDtmfData data)
330 CallBurstDtmfStruct callBurstStruct = new CallBurstDtmfStruct();
331 callBurstStruct.Dtmf = data.Dtmf;
332 callBurstStruct.Width = data.Width;
333 callBurstStruct.Interval = data.Interval;
334 return callBurstStruct;
337 internal static CallDeflectDestStruct ConvertByteDestinationToStruct(byte[] number)
339 CallDeflectDestStruct callDeflectStruct = new CallDeflectDestStruct();
340 callDeflectStruct.DestinationNumber = Marshal.AllocHGlobal(83);
341 Marshal.Copy(number, 0, callDeflectStruct.DestinationNumber, Math.Min(83, number.Length));
342 return callDeflectStruct;
345 internal static CallVolumeRecordStruct ConvertVolumeRecordToStruct(CallVolumeRecord record)
347 CallVolumeRecordStruct volumeStruct = new CallVolumeRecordStruct();
348 volumeStruct.Device = record.Device;
349 volumeStruct.Type = record.Type;
350 volumeStruct.Volume = record.Volume;
354 internal static CallSoundPathStruct ConvertSoundPathToStruct(CallSoundPathInfo info)
356 CallSoundPathStruct pathStruct = new CallSoundPathStruct();
357 pathStruct.Path = info.Path;
358 pathStruct.ExVolume = info.ExVolume;