2 * Copyright (c) 2018 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;
22 namespace Tizen.CallManager
25 /// A class which manages call manager events, properties and functions.
27 public class CmClientHandle
29 internal IntPtr _handle = IntPtr.Zero;
30 private event EventHandler<CallStatusChangedEventArgs> _callStatusChanged;
31 private event EventHandler<CallMuteStatusChangedEventArgs> _callMuteStatusChanged;
32 private event EventHandler<CallEventEventArgs> _callEvent;
33 private event EventHandler<DialStatusEventArgs> _dialStatusChanged;
34 private event EventHandler<AudioStatusChangedEventArgs> _audioStateChanged;
35 private event EventHandler<DtmfIndicationEventArgs> _dtmfIndication;
36 private event EventHandler<EventArgs> _goForeGround;
37 private event EventHandler<VoiceRecordStatusEventArgs> _voiceRecordStatusChanged;
39 private Interop.CallManager.CallStatusChangedCallback _callStatusChangedCb;
40 private Interop.CallManager.CallMuteStatusChangedCallback _callMuteStatusChangedCb;
41 private Interop.CallManager.CallEventNotificationCallback _callEventCb;
42 private Interop.CallManager.DialStatusChangedCallback _dialStatusChangedCb;
43 private Interop.CallManager.AudioStateChangedCallback _audioStateChangedCb;
44 private Interop.CallManager.DtmfIndicationChangedCallback _dtmfIndicationChangedCb;
45 private Interop.CallManager.GoForegroundCallback _goForeGroundCb;
46 private Interop.CallManager.VoiceRecordStatusChangedCallback _voiceRecordStatusChangedCb;
48 internal CmClientHandle(IntPtr handle)
54 /// This event is raised when call status changes.
56 public event EventHandler<CallStatusChangedEventArgs> CallStatusChanged
60 if (_callStatusChanged == null)
62 RegisterCallStatusChangedEvent();
65 _callStatusChanged += value;
70 _callStatusChanged -= value;
71 if (_callStatusChanged == null)
73 UnregisterCallStatusChangedEvent();
79 /// This event is raised when the mute status changes.
81 public event EventHandler<CallMuteStatusChangedEventArgs> CallMuteStatusChanged
85 if (_callMuteStatusChanged == null)
87 RegisterCallMuteStatusChangedEvent();
90 _callMuteStatusChanged += value;
95 _callMuteStatusChanged -= value;
96 if (_callMuteStatusChanged == null)
98 UnregisterCallMuteStatusChangedEvent();
104 /// This event is raised when call events change.
106 public event EventHandler<CallEventEventArgs> CallEvent
110 if (_callEvent == null)
112 RegisterCallEventNotification();
121 if (_callEvent == null)
123 UnregisterCallEventNotification();
129 /// This event is raised when dial status changes.
131 public event EventHandler<DialStatusEventArgs> DialStatusChanged
135 if (_dialStatusChanged == null)
137 RegisterDialStatusEvent();
140 _dialStatusChanged += value;
145 _dialStatusChanged -= value;
146 if (_dialStatusChanged == null)
148 UnregisterDialStatusEvent();
154 /// This event is raised when audio status changes.
156 public event EventHandler<AudioStatusChangedEventArgs> AudioStateChanged
160 if (_audioStateChanged == null)
162 RegisterAudioStateChangedEvent();
165 _audioStateChanged += value;
170 _audioStateChanged -= value;
171 if (_audioStateChanged == null)
173 UnregisterAudioStateChangedEvent();
179 /// This event is raised during DTMF indication.
181 public event EventHandler<DtmfIndicationEventArgs> DtmfIndication
185 if (_dtmfIndication == null)
187 RegisterDtmfIndicationEvent();
190 _dtmfIndication += value;
195 _dtmfIndication -= value;
196 if (_dtmfIndication == null)
198 UnregisterDtmfIndicationEvent();
204 /// This event is raised when call comes to foreground.
206 public event EventHandler<EventArgs> GoForeground
210 if (_goForeGround == null)
212 RegisterGoForegroundEvent();
215 _goForeGround += value;
220 _goForeGround -= value;
221 if (_goForeGround == null)
223 UnregisterGoForegroundEvent();
229 /// This event is raised when voice record status is changed.
231 public event EventHandler<VoiceRecordStatusEventArgs> VoiceRecordStatusChanged
235 if (_voiceRecordStatusChanged == null)
237 RegisterVoiceRecordStatusEvent();
240 _voiceRecordStatusChanged += value;
245 _voiceRecordStatusChanged -= value;
246 if (_voiceRecordStatusChanged == null)
248 UnregisterVoiceRecordStatusEvent();
253 private void RegisterCallStatusChangedEvent()
255 _callStatusChangedCb = (CallStatus status, IntPtr number, IntPtr userData) =>
257 _callStatusChanged?.Invoke(null, new CallStatusChangedEventArgs(status, Marshal.PtrToStringAnsi(number)));
259 int ret = Interop.CallManager.SetCallStatusCallback(_handle, _callStatusChangedCb, IntPtr.Zero);
260 if (ret != (int)CmError.None)
262 Log.Error(CmUtility.LogTag, "Failed to set call status changed callback, Error: " + (CmError)ret);
263 CmUtility.ThrowCmException(ret, _handle);
267 private void UnregisterCallStatusChangedEvent()
269 int ret = Interop.CallManager.UnsetCallstatusCallback(_handle);
270 if (ret != (int)CmError.None)
272 Log.Error(CmUtility.LogTag, "Failed to unset call status changed callback, Error: " + (CmError)ret);
273 CmUtility.ThrowCmException(ret, _handle);
277 private void RegisterCallMuteStatusChangedEvent()
279 _callMuteStatusChangedCb = (CallMuteStatus muteStatus, IntPtr userData) =>
281 _callMuteStatusChanged?.Invoke(null, new CallMuteStatusChangedEventArgs(muteStatus));
283 int ret = Interop.CallManager.SetCallMuteStatusCallback(_handle, _callMuteStatusChangedCb, IntPtr.Zero);
284 if (ret != (int)CmError.None)
286 Log.Error(CmUtility.LogTag, "Failed to set call mute status changed callback, Error: " + (CmError)ret);
287 CmUtility.ThrowCmException(ret, _handle);
291 private void UnregisterCallMuteStatusChangedEvent()
293 int ret = Interop.CallManager.UnsetCallMuteStatusCallback(_handle);
294 if (ret != (int)CmError.None)
296 Log.Error(CmUtility.LogTag, "Failed to unset call mute status changed callback, Error: " + (CmError)ret);
297 CmUtility.ThrowCmException(ret, _handle);
301 private void RegisterCallEventNotification()
303 _callEventCb = (CallEvent callEvent, IntPtr eventData, IntPtr userData) =>
305 _callEvent?.Invoke(null, new CallEventEventArgs(callEvent, CmUtility.GetCallEventData(callEvent, eventData)));
307 int ret = Interop.CallManager.SetCallEventCb(_handle, _callEventCb, IntPtr.Zero);
308 if (ret != (int)CmError.None)
310 Log.Error(CmUtility.LogTag, "Failed to set call event notification callback, Error: " + (CmError)ret);
311 CmUtility.ThrowCmException(ret, _handle);
315 private void UnregisterCallEventNotification()
317 int ret = Interop.CallManager.UnsetCallEventCb(_handle);
318 if (ret != (int)CmError.None)
320 Log.Error(CmUtility.LogTag, "Failed to unset call event notification callback, Error: " + (CmError)ret);
321 CmUtility.ThrowCmException(ret, _handle);
325 private void RegisterDialStatusEvent()
327 _dialStatusChangedCb = (DialStatus status, IntPtr userData) =>
329 _dialStatusChanged?.Invoke(null, new DialStatusEventArgs(status));
331 int ret = Interop.CallManager.SetDialStatusCb(_handle, _dialStatusChangedCb, IntPtr.Zero);
332 if (ret != (int)CmError.None)
334 Log.Error(CmUtility.LogTag, "Failed to set dial status changed callback, Error: " + (CmError)ret);
335 CmUtility.ThrowCmException(ret, _handle);
339 private void UnregisterDialStatusEvent()
341 int ret = Interop.CallManager.UnsetDialStatusCb(_handle);
342 if (ret != (int)CmError.None)
344 Log.Error(CmUtility.LogTag, "Failed to unset dial status changed callback, Error: " + (CmError)ret);
345 CmUtility.ThrowCmException(ret, _handle);
349 private void RegisterAudioStateChangedEvent()
351 _audioStateChangedCb = (AudioState state, IntPtr userData) =>
353 _audioStateChanged?.Invoke(null, new AudioStatusChangedEventArgs(state));
355 int ret = Interop.CallManager.SetAudioStateChangedCb(_handle, _audioStateChangedCb, IntPtr.Zero);
356 if (ret != (int)CmError.None)
358 Log.Error(CmUtility.LogTag, "Failed to set audio state changed callback, Error: " + (CmError)ret);
359 CmUtility.ThrowCmException(ret, _handle);
363 private void UnregisterAudioStateChangedEvent()
365 int ret = Interop.CallManager.UnsetAudioStateChangedCb(_handle);
366 if (ret != (int)CmError.None)
368 Log.Error(CmUtility.LogTag, "Failed to unset audio state changed callback, Error: " + (CmError)ret);
369 CmUtility.ThrowCmException(ret, _handle);
373 private void RegisterDtmfIndicationEvent()
375 _dtmfIndicationChangedCb = (DtmfIndication indiType, string number, IntPtr userData) =>
377 _dtmfIndication?.Invoke(null, new DtmfIndicationEventArgs(indiType, number));
379 int ret = Interop.CallManager.SetDtmfIndicationCb(_handle, _dtmfIndicationChangedCb, IntPtr.Zero);
380 if (ret != (int)CmError.None)
382 Log.Error(CmUtility.LogTag, "Failed to set DTMF indication changed callback, Error: " + (CmError)ret);
383 CmUtility.ThrowCmException(ret, _handle);
387 private void UnregisterDtmfIndicationEvent()
389 int ret = Interop.CallManager.UnsetDtmfIndicationCb(_handle);
390 if (ret != (int)CmError.None)
392 Log.Error(CmUtility.LogTag, "Failed to unset DTMF indication changed callback, Error: " + (CmError)ret);
393 CmUtility.ThrowCmException(ret, _handle);
397 private void RegisterGoForegroundEvent()
399 _goForeGroundCb = (IntPtr userData) =>
401 _goForeGround?.Invoke(null, EventArgs.Empty);
403 int ret = Interop.CallManager.SetForegroundCb(_handle, _goForeGroundCb, IntPtr.Zero);
404 if (ret != (int)CmError.None)
406 Log.Error(CmUtility.LogTag, "Failed to set go foreground callback, Error: " + (CmError)ret);
407 CmUtility.ThrowCmException(ret, _handle);
411 private void UnregisterGoForegroundEvent()
413 int ret = Interop.CallManager.UnsetForegroundCb(_handle);
414 if (ret != (int)CmError.None)
416 Log.Error(CmUtility.LogTag, "Failed to unset go foreground callback, Error: " + (CmError)ret);
417 CmUtility.ThrowCmException(ret, _handle);
421 private void RegisterVoiceRecordStatusEvent()
423 _voiceRecordStatusChangedCb = (VrStatus vrStatus, VrStatusExtraType extraType, IntPtr userData) =>
425 _voiceRecordStatusChanged?.Invoke(null, new VoiceRecordStatusEventArgs(vrStatus, extraType));
427 int ret = Interop.CallManager.SetVoiceRecordStatusCb(_handle, _voiceRecordStatusChangedCb, IntPtr.Zero);
428 if (ret != (int)CmError.None)
430 Log.Error(CmUtility.LogTag, "Failed to set voice record status changed callback, Error: " + (CmError)ret);
431 CmUtility.ThrowCmException(ret, _handle);
435 private void UnregisterVoiceRecordStatusEvent()
437 int ret = Interop.CallManager.UnsetVoiceRecordStatusCb(_handle);
438 if (ret != (int)CmError.None)
440 Log.Error(CmUtility.LogTag, "Failed to unset voice record status changed callback, Error: " + (CmError)ret);
441 CmUtility.ThrowCmException(ret, _handle);
446 /// Gets the status of the current call.
448 public CallStatus CallStatus
452 int ret = Interop.CallManager.GetStatus(_handle, out CallStatus status);
453 if (ret != (int)CmError.None)
455 Log.Error(CmUtility.LogTag, "Failed to get call status, Error: " + (CmError)ret);
456 return default(CallStatus);
464 /// Gets the mute status.
466 public CallMuteStatus CallMuteStatus
470 int ret = Interop.CallManager.GetMuteStatus(_handle, out CallMuteStatus status);
471 if (ret != (int)CmError.None)
473 Log.Error(CmUtility.LogTag, "Failed to get call mute status, Error: " + (CmError)ret);
474 return default(CallMuteStatus);
482 /// Gets the audio state.
484 public AudioState AudioState
488 int ret = Interop.CallManager.GetAudioState(_handle, out AudioState state);
489 if (ret != (int)CmError.None)
491 Log.Error(CmUtility.LogTag, "Failed to get audio state, Error: " + (CmError)ret);
492 return default(AudioState);
500 /// Gets the list of call data.
502 public IEnumerable<CallData> AllCalls
506 int ret = Interop.CallManager.GetAllCallList(_handle, out IntPtr list);
507 if (ret != (int)CmError.None)
509 Log.Error(CmUtility.LogTag, "Failed to get all call list, Error: " + (CmError)ret);
513 int length = Interop.GsList.GetLength(list);
516 Log.Debug(CmUtility.LogTag, "Call list is empty");
517 return Enumerable.Empty<CallData>();
520 List<CallData> callList = new List<CallData>();
521 IntPtr callData = IntPtr.Zero;
522 for (int index = 0; index < length; index++)
524 callData = Interop.GsList.GetDataByIndex(list, index);
525 if (callData != IntPtr.Zero)
527 callList.Add(CmUtility.GetCallData(callData));
536 /// Gets the list of conference call data.
538 public IEnumerable<ConferenceCallData> AllConferenceCalls
542 int ret = Interop.CallManager.GetConferenceCallList(_handle, out IntPtr list);
543 if (ret != (int)CmError.None)
545 Log.Error(CmUtility.LogTag, "Failed to get conference call list, Error: " + (CmError)ret);
549 int length = Interop.GsList.GetLength(list);
552 Log.Debug(CmUtility.LogTag, "Conf call list is empty");
553 return Enumerable.Empty<ConferenceCallData>();
555 List<ConferenceCallData> confList = new List<ConferenceCallData>();
556 IntPtr confData = IntPtr.Zero;
557 for (int index = 0; index < length; index++)
559 confData = Interop.GsList.GetDataByIndex(list, index);
560 if (confData != IntPtr.Zero)
562 confList.Add(CmUtility.GetConfCallData(confData));
571 /// Rejects the incoming call.
573 /// <privlevel>partner</privlevel>
574 /// <privilege>http://developer.samsung.com/tizen/privilege/call.reject</privilege>
575 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
576 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
577 public void RejectCall()
579 int ret = Interop.CallManager.RejectCall(_handle);
580 if (ret != (int)CmError.None)
582 Log.Error(CmUtility.LogTag, "Failed to reject call, Error: " + (CmError)ret);
583 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.reject");
588 /// Starts incoming call alert ringtone.
590 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
591 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
592 public void StartAlert()
594 int ret = Interop.CallManager.StartAlert(_handle);
595 if (ret != (int)CmError.None)
597 Log.Error(CmUtility.LogTag, "Failed to start incoming call alert, Error: " + (CmError)ret);
598 CmUtility.ThrowCmException(ret, _handle);
603 /// Stops incoming call alert ringtone.
605 /// <privlevel>partner</privlevel>
606 /// <privilege>http://developer.samsung.com/tizen/privilege/call.reject</privilege>
607 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
608 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
609 public void StopAlert()
611 int ret = Interop.CallManager.StopAlert(_handle);
612 if (ret != (int)CmError.None)
614 Log.Error(CmUtility.LogTag, "Failed to stop incoming call alert, Error: " + (CmError)ret);
615 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.reject");
620 /// Enables call recovery.
622 /// <param name="appId">App ID to be recovered.</param>
623 /// <exception cref="ArgumentNullException">Thrown appId is passed as null.</exception>
624 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
625 public void EnableRecovery(string appId)
629 throw new ArgumentNullException("App ID is null");
632 int ret = Interop.CallManager.EnableRecovery(_handle, appId);
633 if (ret != (int)CmError.None)
635 Log.Error(CmUtility.LogTag, "Failed to enable recovery, Error: " + (CmError)ret);
636 CmUtility.ThrowCmException(ret, _handle);
643 /// <param name="number">Calling number to be dialed.</param>
644 /// <param name="type">Type of the call to be dialed.</param>
645 /// <param name="slot">Multi sim slot type in which the call is dialed.</param>
646 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
647 /// <exception cref="ArgumentNullException">Thrown number is passed as null.</exception>
648 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
649 public void DialCall(string number, CallType type, MultiSimSlot slot)
653 throw new ArgumentNullException("Calling number is null");
656 int ret = Interop.CallManager.DialCall(_handle, number, type, slot);
657 if (ret != (int)CmError.None)
659 Log.Error(CmUtility.LogTag, "Failed to dial call, Error: " + (CmError)ret);
660 CmUtility.ThrowCmException(ret, _handle);
667 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
668 public void SwapCall()
670 int ret = Interop.CallManager.SwapCall(_handle);
671 if (ret != (int)CmError.None)
673 Log.Error(CmUtility.LogTag, "Failed to swap call, Error: " + (CmError)ret);
674 CmUtility.ThrowCmException(ret, _handle);
679 /// Joins a call with another.
681 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
682 public void JoinCall()
684 int ret = Interop.CallManager.JoinCall(_handle);
685 if (ret != (int)CmError.None)
687 Log.Error(CmUtility.LogTag, "Failed to join call, Error: " + (CmError)ret);
688 CmUtility.ThrowCmException(ret, _handle);
695 /// <param name="id">Call id to be splitted.</param>
696 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
697 public void SplitCall(uint id)
699 int ret = Interop.CallManager.SplitCall(_handle, id);
700 if (ret != (int)CmError.None)
702 Log.Error(CmUtility.LogTag, "Failed to split call, Error: " + (CmError)ret);
703 CmUtility.ThrowCmException(ret, _handle);
708 /// Transfers a call.
710 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
711 public void TransferCall()
713 int ret = Interop.CallManager.TransferCall(_handle);
714 if (ret != (int)CmError.None)
716 Log.Error(CmUtility.LogTag, "Failed to transfer call, Error: " + (CmError)ret);
717 CmUtility.ThrowCmException(ret, _handle);
722 /// Accepts MT ViLTE call as VoLTE.
724 /// <param name="answerType">Call answer type.</param>
725 /// <param name="type">Call type.</param>
726 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
727 public void AnswerCallEx(CallAnswerType answerType, CallType type)
729 int ret = Interop.CallManager.AnswerCallEx(_handle, answerType, type);
730 if (ret != (int)CmError.None)
732 Log.Error(CmUtility.LogTag, "Failed to answer call, Error: " + (CmError)ret);
733 CmUtility.ThrowCmException(ret, _handle);
738 /// Answers an incoming call.
740 /// <param name="answerType">Call answer type.</param>
741 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
742 public void AnswerCall(CallAnswerType answerType)
744 int ret = Interop.CallManager.AnswerCall(_handle, answerType);
745 if (ret != (int)CmError.None)
747 Log.Error(CmUtility.LogTag, "Failed to answer call, Error: " + (CmError)ret);
748 CmUtility.ThrowCmException(ret, _handle);
755 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
756 public void UpgradeCall()
758 int ret = Interop.CallManager.UpgradeCall(_handle);
759 if (ret != (int)CmError.None)
761 Log.Error(CmUtility.LogTag, "Failed to upgrade call, Error: " + (CmError)ret);
762 CmUtility.ThrowCmException(ret, _handle);
767 /// Downgrades a call.
769 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
770 public void DowngradeCall()
772 int ret = Interop.CallManager.DowngradeCall(_handle);
773 if (ret != (int)CmError.None)
775 Log.Error(CmUtility.LogTag, "Failed to downgrade call, Error: " + (CmError)ret);
776 CmUtility.ThrowCmException(ret, _handle);
781 /// Confirms upgrade call request.
783 /// <param name="response">Upgrade response type.</param>
784 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
785 public void ConfirmUpgradeCall(CallUpgradeResponseType response)
787 int ret = Interop.CallManager.ConfirmUpgradeCall(_handle, response);
788 if (ret != (int)CmError.None)
790 Log.Error(CmUtility.LogTag, "Failed to confirm upgrade call, Error: " + (CmError)ret);
791 CmUtility.ThrowCmException(ret, _handle);
796 /// Sets the speaker on/off.
798 /// <param name="status">Status of the speaker to be set.</param>
799 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
800 public void ManageSpeaker(FeatureStatus status)
803 if (status == FeatureStatus.Off)
805 ret = Interop.CallManager.SpeakerOff(_handle);
808 else if (status == FeatureStatus.On)
810 ret = Interop.CallManager.SpeakerOn(_handle);
813 if (ret != (int)CmError.None)
815 Log.Error(CmUtility.LogTag, "Failed to manage speaker, Error: " + (CmError)ret);
816 CmUtility.ThrowCmException(ret, _handle);
821 /// Sets the bluetooth feature on/off.
823 /// <param name="status">Status of the bluetooth to be set.</param>
824 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
825 public void ManageBluetooth(FeatureStatus status)
828 if (status == FeatureStatus.Off)
830 ret = Interop.CallManager.BluetoothOff(_handle);
833 else if (status == FeatureStatus.On)
835 ret = Interop.CallManager.BluetoothOn(_handle);
838 if (ret != (int)CmError.None)
840 Log.Error(CmUtility.LogTag, "Failed to manage bluetooth, Error: " + (CmError)ret);
841 CmUtility.ThrowCmException(ret, _handle);
846 /// Sets extra volume if needed.
848 /// <param name="isExtraVolume">Boolean value to indicate if the call is set to have extra volume.</param>
849 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
850 public void SetExtraVolume(bool isExtraVolume)
852 int ret = Interop.CallManager.SetExtraVolume(_handle, isExtraVolume);
853 if (ret != (int)CmError.None)
855 Log.Error(CmUtility.LogTag, "Failed to set extra volume, Error: " + (CmError)ret);
856 CmUtility.ThrowCmException(ret, _handle);
861 /// Sets the noise reduction feature during call.
863 /// <param name="isNoiceReduction">Boolean value to indicate whether the call needs noise reduction.</param>
864 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
865 public void SetNoiseReduction(bool isNoiceReduction)
867 int ret = Interop.CallManager.SetNoiseReduction(_handle, isNoiceReduction);
868 if (ret != (int)CmError.None)
870 Log.Error(CmUtility.LogTag, "Failed to set noise reduction, Error: " + (CmError)ret);
871 CmUtility.ThrowCmException(ret, _handle);
876 /// Sets the mute state of the call.
878 /// <param name="isMuteState">Mute state to be set.</param>
879 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
880 public void SetMuteState(bool isMuteState)
882 int ret = Interop.CallManager.SetMuteState(_handle, isMuteState);
883 if (ret != (int)CmError.None)
885 Log.Error(CmUtility.LogTag, "Failed to set mute state, Error: " + (CmError)ret);
886 CmUtility.ThrowCmException(ret, _handle);
891 /// Starts sending signal through DTMF digit.
893 /// <param name="dtmfDigit">DTMF digit to be pressed on the phone.</param>
894 /// <exception cref="ArgumentException">Thrown when method failed due to invalid parameter.</exception>
895 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
896 public void StartDtmf(byte dtmfDigit)
898 int ret = Interop.CallManager.StartDtmf(_handle, dtmfDigit);
899 if (ret != (int)CmError.None)
901 Log.Error(CmUtility.LogTag, "Failed to start DTMF, Error: " + (CmError)ret);
902 CmUtility.ThrowCmException(ret, _handle);
907 /// Stops sending DTMF signal.
909 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
910 public void StopDtmf()
912 int ret = Interop.CallManager.StopDtmf(_handle);
913 if (ret != (int)CmError.None)
915 Log.Error(CmUtility.LogTag, "Failed to stop DTMF, Error: " + (CmError)ret);
916 CmUtility.ThrowCmException(ret, _handle);
921 /// Sends signal through DTMF digits.
923 /// <param name="dtmfDigits">DTMF digits.</param>
924 /// <exception cref="ArgumentNullException">Thrown when dtmfDigits is passed as null.</exception>
925 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
926 public void BurstDtmf(string dtmfDigits)
928 if (dtmfDigits == null)
930 throw new ArgumentNullException("DTMF digits is null");
933 int ret = Interop.CallManager.BurstDtmf(_handle, dtmfDigits);
934 if (ret != (int)CmError.None)
936 Log.Error(CmUtility.LogTag, "Failed to burst DTMF, Error: " + (CmError)ret);
937 CmUtility.ThrowCmException(ret, _handle);
942 /// Sends DTMF response.
944 /// <param name="response">DTMF response type.</param>
945 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
946 public void SendDtmfResponse(DtmfResponseType response)
948 int ret = Interop.CallManager.SendDtmfResponse(_handle, response);
949 if (ret != (int)CmError.None)
951 Log.Error(CmUtility.LogTag, "Failed to send DTMF response, Error: " + (CmError)ret);
952 CmUtility.ThrowCmException(ret, _handle);
957 /// Activates call manager UI.
959 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
960 public void ActivateUi()
962 int ret = Interop.CallManager.ActivateUi(_handle);
963 if (ret != (int)CmError.None)
965 Log.Error(CmUtility.LogTag, "Failed to activate UI, Error: " + (CmError)ret);
966 CmUtility.ThrowCmException(ret, _handle);
971 /// Sets device LCD time out.
973 /// <param name="timeout">LCD timeout to be set.</param>
974 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
975 public void SetLcdTimeout(LcdTimeOut timeout)
977 int ret = Interop.CallManager.SetLcdTimeOut(_handle, timeout);
978 if (ret != (int)CmError.None)
980 Log.Error(CmUtility.LogTag, "Failed to set LCD timeout, Error: " + (CmError)ret);
981 CmUtility.ThrowCmException(ret, _handle);
986 /// Starts voice recording.
988 /// <param name="number">Call number.</param>
989 /// <exception cref="ArgumentNullException">Thrown when number is passed as null.</exception>
990 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
991 public void StartVoiceRecord(string number)
995 throw new ArgumentNullException("Call number is null");
998 int ret = Interop.CallManager.StartVoiceRecord(_handle, number);
999 if (ret != (int)CmError.None)
1001 Log.Error(CmUtility.LogTag, "Failed to start voice record, Error: " + (CmError)ret);
1002 CmUtility.ThrowCmException(ret, _handle);
1007 /// Stops voice record.
1009 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1010 public void StopVoiceRecord()
1012 int ret = Interop.CallManager.StopVoiceRecord(_handle);
1013 if (ret != (int)CmError.None)
1015 Log.Error(CmUtility.LogTag, "Failed to stop voice record, Error: " + (CmError)ret);
1016 CmUtility.ThrowCmException(ret, _handle);
1021 /// Gets all current call data.
1023 /// <param name="incoming">Incoming calldata instance to be filled.</param>
1024 /// <param name="active">Active calldata instance to be filled.</param>
1025 /// <param name="held">Held calldata instance to be filled.</param>
1026 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1027 public void GetAllCallData(out CallData incoming, out CallData active, out CallData held)
1029 int ret = Interop.CallManager.GetAllCallData(_handle, out IntPtr incomingCall, out IntPtr activeCall, out IntPtr heldCall);
1030 if (ret != (int)CmError.None)
1032 Log.Error(CmUtility.LogTag, "Failed to get all call data, Error: " + (CmError)ret);
1033 CmUtility.ThrowCmException(ret, _handle);
1036 incoming = CmUtility.GetCallData(incomingCall);
1037 active = CmUtility.GetCallData(activeCall);
1038 held = CmUtility.GetCallData(heldCall);
1042 /// Holds the active call.
1044 /// <privlevel>platform</privlevel>
1045 /// <privilege>http://developer.samsung.com/tizen/privilege/call.admin</privilege>
1046 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1047 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1048 public void HoldCall()
1050 int ret = Interop.CallManager.HoldCall(_handle);
1051 if (ret != (int)CmError.None)
1053 Log.Error(CmUtility.LogTag, "Failed to hold call, Error: " + (CmError)ret);
1054 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin");
1059 /// Unholds the active call.
1061 /// <privlevel>platform</privlevel>
1062 /// <privilege>http://developer.samsung.com/tizen/privilege/call.admin</privilege>
1063 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1064 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1065 public void UnholdCall()
1067 int ret = Interop.CallManager.UnholdCall(_handle);
1068 if (ret != (int)CmError.None)
1070 Log.Error(CmUtility.LogTag, "Failed to unhold call, Error: " + (CmError)ret);
1071 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin");
1076 /// Ends ongoing call.
1078 /// <param name="id">ID of the call which is to be ended.</param>
1079 /// <param name="type">Call release type.</param>
1080 /// <privlevel>platform</privlevel>
1081 /// <privilege>http://developer.samsung.com/tizen/privilege/call.admin</privilege>
1082 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1083 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1084 public void EndCall(uint id, CallReleaseType type)
1086 int ret = Interop.CallManager.EndCall(_handle, id, type);
1087 if (ret != (int)CmError.None)
1089 Log.Error(CmUtility.LogTag, "Failed to end call, Error: " + (CmError)ret);
1090 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin");