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;
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);
445 public CallStatus CallStatus
449 int ret = Interop.CallManager.GetStatus(_handle, out CallStatus status);
450 if (ret != (int)CmError.None)
452 Log.Error(CmUtility.LogTag, "Failed to get call status, Error: " + (CmError)ret);
453 return default(CallStatus);
461 /// Gets the mute status.
463 public CallMuteStatus CallMuteStatus
467 int ret = Interop.CallManager.GetMuteStatus(_handle, out CallMuteStatus status);
468 if (ret != (int)CmError.None)
470 Log.Error(CmUtility.LogTag, "Failed to get call mute status, Error: " + (CmError)ret);
471 return default(CallMuteStatus);
479 /// Gets the audio state.
481 public AudioState AudioState
485 int ret = Interop.CallManager.GetAudioState(_handle, out AudioState state);
486 if (ret != (int)CmError.None)
488 Log.Error(CmUtility.LogTag, "Failed to get audio state, Error: " + (CmError)ret);
489 return default(AudioState);
497 /// Gets the list of call data.
499 public IEnumerable<CallData> AllCalls
503 int ret = Interop.CallManager.GetAllCallList(_handle, out IntPtr list);
504 if (ret != (int)CmError.None)
506 Log.Error(CmUtility.LogTag, "Failed to get all call list, Error: " + (CmError)ret);
510 int length = Interop.GsList.GetLength(list);
513 Log.Debug(CmUtility.LogTag, "Call list is empty");
514 return Enumerable.Empty<CallData>();
517 List<CallData> callList = new List<CallData>();
518 IntPtr callData = IntPtr.Zero;
519 for (int index = 0; index < length; index++)
521 callData = Interop.GsList.GetDataByIndex(list, index);
522 if (callData != IntPtr.Zero)
524 callList.Add(CmUtility.GetCallData(callData));
533 /// Gets the list of conference call data.
535 public IEnumerable<ConferenceCallData> AllConferenceCalls
539 int ret = Interop.CallManager.GetConferenceCallList(_handle, out IntPtr list);
540 if (ret != (int)CmError.None)
542 Log.Error(CmUtility.LogTag, "Failed to get conference call list, Error: " + (CmError)ret);
546 int length = Interop.GsList.GetLength(list);
549 Log.Debug(CmUtility.LogTag, "Conf call list is empty");
550 return Enumerable.Empty<ConferenceCallData>();
552 List<ConferenceCallData> confList = new List<ConferenceCallData>();
553 IntPtr confData = IntPtr.Zero;
554 for (int index = 0; index < length; index++)
556 confData = Interop.GsList.GetDataByIndex(list, index);
557 if (confData != IntPtr.Zero)
559 confList.Add(CmUtility.GetConfCallData(confData));
568 /// Rejects the incoming call.
570 /// <privlevel>partner</privlevel>
571 /// <privilege>http://developer.samsung.com/tizen/privilege/call.reject</privilege>
572 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
573 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
574 public void RejectCall()
576 int ret = Interop.CallManager.RejectCall(_handle);
577 if (ret != (int)CmError.None)
579 Log.Error(CmUtility.LogTag, "Failed to reject call, Error: " + (CmError)ret);
580 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.reject");
585 /// Starts incoming call alert ringtone.
587 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
588 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
589 public void StartAlert()
591 int ret = Interop.CallManager.StartAlert(_handle);
592 if (ret != (int)CmError.None)
594 Log.Error(CmUtility.LogTag, "Failed to start incoming call alert, Error: " + (CmError)ret);
595 CmUtility.ThrowCmException(ret, _handle);
600 /// Stops incoming call alert ringtone.
602 /// <privlevel>partner</privlevel>
603 /// <privilege>http://developer.samsung.com/tizen/privilege/call.reject</privilege>
604 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
605 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
606 public void StopAlert()
608 int ret = Interop.CallManager.StopAlert(_handle);
609 if (ret != (int)CmError.None)
611 Log.Error(CmUtility.LogTag, "Failed to stop incoming call alert, Error: " + (CmError)ret);
612 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.reject");
617 /// Enables call recovery.
619 /// <param name="appId">App ID to be recovered.</param>
620 /// <exception cref="ArgumentNullException">Thrown appId is passed as null.</exception>
621 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
622 public void EnableRecovery(string appId)
626 throw new ArgumentNullException("App ID is null");
629 int ret = Interop.CallManager.EnableRecovery(_handle, appId);
630 if (ret != (int)CmError.None)
632 Log.Error(CmUtility.LogTag, "Failed to enable recovery, Error: " + (CmError)ret);
633 CmUtility.ThrowCmException(ret, _handle);
640 /// <param name="number">Calling number to be dialed.</param>
641 /// <param name="type">Type of the call to be dialed.</param>
642 /// <param name="slot">Multi sim slot type in which the call is dialed.</param>
643 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
644 /// <exception cref="ArgumentNullException">Thrown number is passed as null.</exception>
645 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
646 public void DialCall(string number, CallType type, MultiSimSlot slot)
650 throw new ArgumentNullException("Calling number is null");
653 int ret = Interop.CallManager.DialCall(_handle, number, type, slot);
654 if (ret != (int)CmError.None)
656 Log.Error(CmUtility.LogTag, "Failed to dial call, Error: " + (CmError)ret);
657 CmUtility.ThrowCmException(ret, _handle);
664 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
665 public void SwapCall()
667 int ret = Interop.CallManager.SwapCall(_handle);
668 if (ret != (int)CmError.None)
670 Log.Error(CmUtility.LogTag, "Failed to swap call, Error: " + (CmError)ret);
671 CmUtility.ThrowCmException(ret, _handle);
676 /// Joins a call with another.
678 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
679 public void JoinCall()
681 int ret = Interop.CallManager.JoinCall(_handle);
682 if (ret != (int)CmError.None)
684 Log.Error(CmUtility.LogTag, "Failed to join call, Error: " + (CmError)ret);
685 CmUtility.ThrowCmException(ret, _handle);
692 /// <param name="id">Call id to be splitted.</param>
693 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
694 public void SplitCall(uint id)
696 int ret = Interop.CallManager.SplitCall(_handle, id);
697 if (ret != (int)CmError.None)
699 Log.Error(CmUtility.LogTag, "Failed to split call, Error: " + (CmError)ret);
700 CmUtility.ThrowCmException(ret, _handle);
705 /// Transfers a call.
707 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
708 public void TransferCall()
710 int ret = Interop.CallManager.TransferCall(_handle);
711 if (ret != (int)CmError.None)
713 Log.Error(CmUtility.LogTag, "Failed to transfer call, Error: " + (CmError)ret);
714 CmUtility.ThrowCmException(ret, _handle);
719 /// Accepts MT ViLTE call as VoLTE.
721 /// <param name="answerType">Call answer type.</param>
722 /// <param name="type">Call type.</param>
723 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
724 public void AnswerCallEx(CallAnswerType answerType, CallType type)
726 int ret = Interop.CallManager.AnswerCallEx(_handle, answerType, type);
727 if (ret != (int)CmError.None)
729 Log.Error(CmUtility.LogTag, "Failed to answer call, Error: " + (CmError)ret);
730 CmUtility.ThrowCmException(ret, _handle);
735 /// Answers an incoming call.
737 /// <param name="answerType">Call answer type.</param>
738 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
739 public void AnswerCall(CallAnswerType answerType)
741 int ret = Interop.CallManager.AnswerCall(_handle, answerType);
742 if (ret != (int)CmError.None)
744 Log.Error(CmUtility.LogTag, "Failed to answer call, Error: " + (CmError)ret);
745 CmUtility.ThrowCmException(ret, _handle);
752 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
753 public void UpgradeCall()
755 int ret = Interop.CallManager.UpgradeCall(_handle);
756 if (ret != (int)CmError.None)
758 Log.Error(CmUtility.LogTag, "Failed to upgrade call, Error: " + (CmError)ret);
759 CmUtility.ThrowCmException(ret, _handle);
764 /// Downgrades a call.
766 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
767 public void DowngradeCall()
769 int ret = Interop.CallManager.DowngradeCall(_handle);
770 if (ret != (int)CmError.None)
772 Log.Error(CmUtility.LogTag, "Failed to downgrade call, Error: " + (CmError)ret);
773 CmUtility.ThrowCmException(ret, _handle);
778 /// Confirms upgrade call request.
780 /// <param name="response">Upgrade response type.</param>
781 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
782 public void ConfirmUpgradeCall(CallUpgradeResponseType response)
784 int ret = Interop.CallManager.ConfirmUpgradeCall(_handle, response);
785 if (ret != (int)CmError.None)
787 Log.Error(CmUtility.LogTag, "Failed to confirm upgrade call, Error: " + (CmError)ret);
788 CmUtility.ThrowCmException(ret, _handle);
793 /// Sets the speaker on/off.
795 /// <param name="status">Status of the speaker to be set.</param>
796 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
797 public void ManageSpeaker(FeatureStatus status)
800 if (status == FeatureStatus.Off)
802 ret = Interop.CallManager.SpeakerOff(_handle);
805 else if (status == FeatureStatus.On)
807 ret = Interop.CallManager.SpeakerOn(_handle);
810 if (ret != (int)CmError.None)
812 Log.Error(CmUtility.LogTag, "Failed to manage speaker, Error: " + (CmError)ret);
813 CmUtility.ThrowCmException(ret, _handle);
818 /// Sets the bluetooth feature on/off.
820 /// <param name="status">Status of the bluetooth to be set.</param>
821 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
822 public void ManageBluetooth(FeatureStatus status)
825 if (status == FeatureStatus.Off)
827 ret = Interop.CallManager.BluetoothOff(_handle);
830 else if (status == FeatureStatus.On)
832 ret = Interop.CallManager.BluetoothOn(_handle);
835 if (ret != (int)CmError.None)
837 Log.Error(CmUtility.LogTag, "Failed to manage bluetooth, Error: " + (CmError)ret);
838 CmUtility.ThrowCmException(ret, _handle);
843 /// Sets extra volume if needed.
845 /// <param name="isExtraVolume">Boolean value to indicate if the call is set to have extra volume.</param>
846 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
847 public void SetExtraVolume(bool isExtraVolume)
849 int ret = Interop.CallManager.SetExtraVolume(_handle, isExtraVolume);
850 if (ret != (int)CmError.None)
852 Log.Error(CmUtility.LogTag, "Failed to set extra volume, Error: " + (CmError)ret);
853 CmUtility.ThrowCmException(ret, _handle);
858 /// Sets the noise reduction feature during call.
860 /// <param name="isNoiceReduction">Boolean value to indicate whether the call needs noise reduction.</param>
861 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
862 public void SetNoiseReduction(bool isNoiceReduction)
864 int ret = Interop.CallManager.SetNoiseReduction(_handle, isNoiceReduction);
865 if (ret != (int)CmError.None)
867 Log.Error(CmUtility.LogTag, "Failed to set noise reduction, Error: " + (CmError)ret);
868 CmUtility.ThrowCmException(ret, _handle);
873 /// Sets the mute state of the call.
875 /// <param name="isMuteState">Mute state to be set.</param>
876 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
877 public void SetMuteState(bool isMuteState)
879 int ret = Interop.CallManager.SetMuteState(_handle, isMuteState);
880 if (ret != (int)CmError.None)
882 Log.Error(CmUtility.LogTag, "Failed to set mute state, Error: " + (CmError)ret);
883 CmUtility.ThrowCmException(ret, _handle);
888 /// Starts sending signal through DTMF digit.
890 /// <param name="dtmfDigit">DTMF digit to be pressed on the phone.</param>
891 /// <exception cref="ArgumentException">Thrown when method failed due to invalid parameter.</exception>
892 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
893 public void StartDtmf(byte dtmfDigit)
895 int ret = Interop.CallManager.StartDtmf(_handle, dtmfDigit);
896 if (ret != (int)CmError.None)
898 Log.Error(CmUtility.LogTag, "Failed to start DTMF, Error: " + (CmError)ret);
899 CmUtility.ThrowCmException(ret, _handle);
904 /// Stops sending DTMF signal.
906 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
907 public void StopDtmf()
909 int ret = Interop.CallManager.StopDtmf(_handle);
910 if (ret != (int)CmError.None)
912 Log.Error(CmUtility.LogTag, "Failed to stop DTMF, Error: " + (CmError)ret);
913 CmUtility.ThrowCmException(ret, _handle);
918 /// Sends signal through DTMF digits.
920 /// <param name="dtmfDigits">DTMF digits.</param>
921 /// <exception cref="ArgumentNullException">Thrown when dtmfDigits is passed as null.</exception>
922 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
923 public void BurstDtmf(string dtmfDigits)
925 if (dtmfDigits == null)
927 throw new ArgumentNullException("DTMF digits is null");
930 int ret = Interop.CallManager.BurstDtmf(_handle, dtmfDigits);
931 if (ret != (int)CmError.None)
933 Log.Error(CmUtility.LogTag, "Failed to burst DTMF, Error: " + (CmError)ret);
934 CmUtility.ThrowCmException(ret, _handle);
939 /// Sends DTMF response.
941 /// <param name="response">DTMF response type.</param>
942 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
943 public void SendDtmfResponse(DtmfResponseType response)
945 int ret = Interop.CallManager.SendDtmfResponse(_handle, response);
946 if (ret != (int)CmError.None)
948 Log.Error(CmUtility.LogTag, "Failed to send DTMF response, Error: " + (CmError)ret);
949 CmUtility.ThrowCmException(ret, _handle);
954 /// Activates call manager UI.
956 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
957 public void ActivateUi()
959 int ret = Interop.CallManager.ActivateUi(_handle);
960 if (ret != (int)CmError.None)
962 Log.Error(CmUtility.LogTag, "Failed to activate UI, Error: " + (CmError)ret);
963 CmUtility.ThrowCmException(ret, _handle);
968 /// Sets device LCD time out.
970 /// <param name="timeout">LCD timeout to be set.</param>
971 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
972 public void SetLcdTimeout(LcdTimeOut timeout)
974 int ret = Interop.CallManager.SetLcdTimeOut(_handle, timeout);
975 if (ret != (int)CmError.None)
977 Log.Error(CmUtility.LogTag, "Failed to set LCD timeout, Error: " + (CmError)ret);
978 CmUtility.ThrowCmException(ret, _handle);
983 /// Starts voice recording.
985 /// <param name="number">Call number.</param>
986 /// <exception cref="ArgumentNullException">Thrown when number is passed as null.</exception>
987 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
988 public void StartVoiceRecord(string number)
992 throw new ArgumentNullException("Call number is null");
995 int ret = Interop.CallManager.StartVoiceRecord(_handle, number);
996 if (ret != (int)CmError.None)
998 Log.Error(CmUtility.LogTag, "Failed to start voice record, Error: " + (CmError)ret);
999 CmUtility.ThrowCmException(ret, _handle);
1004 /// Stops voice record.
1006 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1007 public void StopVoiceRecord()
1009 int ret = Interop.CallManager.StopVoiceRecord(_handle);
1010 if (ret != (int)CmError.None)
1012 Log.Error(CmUtility.LogTag, "Failed to stop voice record, Error: " + (CmError)ret);
1013 CmUtility.ThrowCmException(ret, _handle);
1018 /// Gets all current call data.
1020 /// <param name="incoming">Incoming calldata instance to be filled.</param>
1021 /// <param name="active">Active calldata instance to be filled.</param>
1022 /// <param name="held">Held calldata instance to be filled.</param>
1023 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1024 public void GetAllCallData(out CallData incoming, out CallData active, out CallData held)
1026 int ret = Interop.CallManager.GetAllCallData(_handle, out IntPtr incomingCall, out IntPtr activeCall, out IntPtr heldCall);
1027 if (ret != (int)CmError.None)
1029 Log.Error(CmUtility.LogTag, "Failed to get all call data, Error: " + (CmError)ret);
1030 CmUtility.ThrowCmException(ret, _handle);
1033 incoming = CmUtility.GetCallData(incomingCall);
1034 active = CmUtility.GetCallData(activeCall);
1035 held = CmUtility.GetCallData(heldCall);
1039 /// Holds the active call.
1041 /// <privlevel>platform</privlevel>
1042 /// <privilege>http://developer.samsung.com/tizen/privilege/call.admin</privilege>
1043 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1044 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1045 public void HoldCall()
1047 int ret = Interop.CallManager.HoldCall(_handle);
1048 if (ret != (int)CmError.None)
1050 Log.Error(CmUtility.LogTag, "Failed to hold call, Error: " + (CmError)ret);
1051 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin");
1056 /// Unholds the active call.
1058 /// <privlevel>platform</privlevel>
1059 /// <privilege>http://developer.samsung.com/tizen/privilege/call.admin</privilege>
1060 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1061 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1062 public void UnholdCall()
1064 int ret = Interop.CallManager.UnholdCall(_handle);
1065 if (ret != (int)CmError.None)
1067 Log.Error(CmUtility.LogTag, "Failed to unhold call, Error: " + (CmError)ret);
1068 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin");
1073 /// Ends ongoing call.
1075 /// <param name="id">ID of the call which is to be ended.</param>
1076 /// <param name="type">Call release type.</param>
1077 /// <privlevel>platform</privlevel>
1078 /// <privilege>http://developer.samsung.com/tizen/privilege/call.admin</privilege>
1079 /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception>
1080 /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation.</exception>
1081 public void EndCall(uint id, CallReleaseType type)
1083 int ret = Interop.CallManager.EndCall(_handle, id, type);
1084 if (ret != (int)CmError.None)
1086 Log.Error(CmUtility.LogTag, "Failed to end call, Error: " + (CmError)ret);
1087 CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin");