From be2cece8894615ce1314c6f54c3baa6e1a6d90bb Mon Sep 17 00:00:00 2001 From: "adhavan.m" Date: Mon, 21 Aug 2017 17:53:09 +0530 Subject: [PATCH] [CallManager] Implementation of call-manager APIs. Change-Id: I1ef4ff8275efb3ee1dc22eef83cab280e2cb11ec Signed-off-by: adhavan.m --- pkg/Tizen.NET.Private.sln | 14 + .../Interop/Interop.CallManager.cs | 227 ++++ src/Tizen.CallManager/Interop/Interop.Libraries.cs | 25 + src/Tizen.CallManager/Tizen.CallManager.csproj | 14 + src/Tizen.CallManager/Tizen.CallManager.sln | 61 ++ .../Tizen.CallManager/CallData.cs | 271 +++++ .../Tizen.CallManager/CallEventData.cs | 102 ++ .../Tizen.CallManager/CallManager.cs | 83 ++ .../Tizen.CallManager/CmClientHandle.cs | 1087 ++++++++++++++++++++ .../Tizen.CallManager/CmEnumerations.cs | 692 +++++++++++++ .../Tizen.CallManager/CmEventArgs.cs | 240 +++++ .../Tizen.CallManager/CmUtility.cs | 425 ++++++++ .../Tizen.CallManager/ConferenceCallData.cs | 78 ++ 13 files changed, 3319 insertions(+) create mode 100755 src/Tizen.CallManager/Interop/Interop.CallManager.cs create mode 100755 src/Tizen.CallManager/Interop/Interop.Libraries.cs create mode 100644 src/Tizen.CallManager/Tizen.CallManager.csproj create mode 100755 src/Tizen.CallManager/Tizen.CallManager.sln create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CallData.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CallEventData.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CallManager.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CmClientHandle.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CmEnumerations.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CmEventArgs.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/CmUtility.cs create mode 100755 src/Tizen.CallManager/Tizen.CallManager/ConferenceCallData.cs diff --git a/pkg/Tizen.NET.Private.sln b/pkg/Tizen.NET.Private.sln index 70d094d..c4448d0 100644 --- a/pkg/Tizen.NET.Private.sln +++ b/pkg/Tizen.NET.Private.sln @@ -165,6 +165,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Uix.VoiceControl", ". EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.WebView", "..\src\Tizen.WebView\Tizen.WebView.csproj", "{8D3289A5-591B-421D-A79C-776B9AC74B95}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.CallManager", "..\src\Tizen.CallManager\Tizen.CallManager.csproj", "{05DD16B8-2027-4728-AEB6-6296E7457533}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1150,5 +1152,17 @@ Global {8D3289A5-591B-421D-A79C-776B9AC74B95}.Release|x64.Build.0 = Release|x64 {8D3289A5-591B-421D-A79C-776B9AC74B95}.Release|x86.ActiveCfg = Release|x86 {8D3289A5-591B-421D-A79C-776B9AC74B95}.Release|x86.Build.0 = Release|x86 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {05DD16B8-2027-4728-AEB6-6296E7457533}.Debug|Any CPU.Build.0 = Debug|Any CPU + {05DD16B8-2027-4728-AEB6-6296E7457533}.Debug|x64.ActiveCfg = Debug|x64 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Debug|x64.Build.0 = Debug|x64 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Debug|x86.ActiveCfg = Debug|x86 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Debug|x86.Build.0 = Debug|x86 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Release|Any CPU.ActiveCfg = Release|Any CPU + {05DD16B8-2027-4728-AEB6-6296E7457533}.Release|Any CPU.Build.0 = Release|Any CPU + {05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x64.ActiveCfg = Release|x64 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x64.Build.0 = Release|x64 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x86.ActiveCfg = Release|x86 + {05DD16B8-2027-4728-AEB6-6296E7457533}.Release|x86.Build.0 = Release|x86 EndGlobalSection EndGlobal diff --git a/src/Tizen.CallManager/Interop/Interop.CallManager.cs b/src/Tizen.CallManager/Interop/Interop.CallManager.cs new file mode 100755 index 0000000..f4d3c4b --- /dev/null +++ b/src/Tizen.CallManager/Interop/Interop.CallManager.cs @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; +using Tizen.CallManager; + +/// +/// Interop class for CallManager +/// +internal static partial class Interop +{ + /// + /// CallManager Native Apis + /// + internal static partial class CallManager + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void CallStatusChangedCallback(CallStatus callStatus, string number, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void CallMuteStatusChangedCallback(CallMuteStatus muteStatus, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void DialStatusChangedCallback(DialStatus dialStatus, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void DtmfIndicationChangedCallback(DtmfIndication indiType, string number, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void AudioStateChangedCallback(AudioState state, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void GoForegroundCallback(IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void VoiceRecordStatusChangedCallback(VrStatus vrStatus, VrStatusExtraType extraType, IntPtr userData); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void CallEventNotificationCallback(CallEvent callEvent, IntPtr eventData, IntPtr userData); + + [DllImport(Libraries.CallManager, EntryPoint = "cm_init")] + internal static extern int InitCm(out IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_deinit")] + internal static extern int DeinitCm(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_reject_call")] + internal static extern int RejectCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_stop_alert")] + internal static extern int StopAlert(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_get_call_status")] + internal static extern int GetStatus(IntPtr handle, out CallStatus callStatus); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_call_status_cb")] + internal static extern int SetCallStatusCallback(IntPtr handle, CallStatusChangedCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_call_status_cb")] + internal static extern int UnsetCallstatusCallback(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_get_mute_status")] + internal static extern int GetMuteStatus(IntPtr handle, out CallMuteStatus muteStatus); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_mute_status_cb")] + internal static extern int SetCallMuteStatusCallback(IntPtr handle, CallMuteStatusChangedCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_mute_status_cb")] + internal static extern int UnsetCallMuteStatusCallback(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_enable_recovery")] + internal static extern int EnableRecovery(IntPtr handle, string appId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_dial_call")] + internal static extern int DialCall(IntPtr handle, string number, CallType type, MultiSimSlot simSlot); + [DllImport(Libraries.CallManager, EntryPoint = "cm_swap_call")] + internal static extern int SwapCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_join_call")] + internal static extern int JoinCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_split_call")] + internal static extern int SplitCall(IntPtr handle, uint callId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_transfer_call")] + internal static extern int TransferCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_answer_call_ex")] + internal static extern int AnswerCallEx(IntPtr handle, CallAnswerType answerType, CallType callType); + [DllImport(Libraries.CallManager, EntryPoint = "cm_answer_call")] + internal static extern int AnswerCall(IntPtr handle, CallAnswerType answerType); + [DllImport(Libraries.CallManager, EntryPoint = "cm_upgrade_call")] + internal static extern int UpgradeCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_downgrade_call")] + internal static extern int DowngradeCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_confirm_upgrade_call")] + internal static extern int ConfirmUpgradeCall(IntPtr handle, CallUpgradeResponseType respType); + [DllImport(Libraries.CallManager, EntryPoint = "cm_speaker_on")] + internal static extern int SpeakerOn(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_speaker_off")] + internal static extern int SpeakerOff(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_bluetooth_on")] + internal static extern int BluetoothOn(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_bluetooth_off")] + internal static extern int BluetoothOff(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_extra_vol")] + internal static extern int SetExtraVolume(IntPtr handle, bool isExtraVolume); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_noise_reduction")] + internal static extern int SetNoiseReduction(IntPtr handle, bool isNoiseReduction); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_mute_state")] + internal static extern int SetMuteState(IntPtr handle, bool isMuteState); + [DllImport(Libraries.CallManager, EntryPoint = "cm_start_dtmf")] + internal static extern int StartDtmf(IntPtr handle, byte dtmfDigit); + [DllImport(Libraries.CallManager, EntryPoint = "cm_stop_dtmf")] + internal static extern int StopDtmf(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_burst_dtmf")] + internal static extern int BurstDtmf(IntPtr handle, string dtmfDigits); + [DllImport(Libraries.CallManager, EntryPoint = "cm_send_dtmf_resp")] + internal static extern int SendDtmfResponse(IntPtr handle, DtmfResponseType respType); + [DllImport(Libraries.CallManager, EntryPoint = "cm_get_audio_state")] + internal static extern int GetAudioState(IntPtr handle, out AudioState state); + [DllImport(Libraries.CallManager, EntryPoint = "cm_activate_ui")] + internal static extern int ActivateUi(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_lcd_timeout")] + internal static extern int SetLcdTimeOut(IntPtr handle, LcdTimeOut timeOut); + [DllImport(Libraries.CallManager, EntryPoint = "cm_get_all_call_list")] + internal static extern int GetAllCallList(IntPtr handle, out IntPtr list); + [DllImport(Libraries.CallManager, EntryPoint = "cm_get_conference_call_list")] + internal static extern int GetConferenceCallList(IntPtr handle, out IntPtr list); + [DllImport(Libraries.CallManager, EntryPoint = "cm_get_all_calldata")] + internal static extern int GetAllCallData(IntPtr handle, out IntPtr incoming, out IntPtr active, out IntPtr held); + [DllImport(Libraries.CallManager, EntryPoint = "cm_start_voice_record")] + internal static extern int StartVoiceRecord(IntPtr handle, string number); + [DllImport(Libraries.CallManager, EntryPoint = "cm_stop_voice_record")] + internal static extern int StopVoiceRecord(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_dial_status_cb")] + internal static extern int SetDialStatusCb(IntPtr handle, DialStatusChangedCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_dial_status_cb")] + internal static extern int UnsetDialStatusCb(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_audio_state_changed_cb")] + internal static extern int SetAudioStateChangedCb(IntPtr handle, AudioStateChangedCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_audio_state_changed_cb")] + internal static extern int UnsetAudioStateChangedCb(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_dtmf_indication_cb")] + internal static extern int SetDtmfIndicationCb(IntPtr handle, DtmfIndicationChangedCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_dtmf_indication_cb")] + internal static extern int UnsetDtmfIndicationCb(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_foreground_cb")] + internal static extern int SetForegroundCb(IntPtr handle, GoForegroundCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_foreground_cb")] + internal static extern int UnsetForegroundCb(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_voice_record_status_cb")] + internal static extern int SetVoiceRecordStatusCb(IntPtr handle, VoiceRecordStatusChangedCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_voice_record_status_cb")] + internal static extern int UnsetVoiceRecordStatusCb(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_person_id")] + internal static extern int GetPersonId(IntPtr handle, out int personId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_member_count")] + internal static extern int GetCallMemberCount(IntPtr handle, out int memberCount); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_is_emergency_call")] + internal static extern int IsEmergencyCall(IntPtr handle, out bool isEmergency); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_is_voicemail_number")] + internal static extern int IsVoiceMailNumber(IntPtr handle, out bool isVoiceMailNumber); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_start_time")] + internal static extern int GetStartTime(IntPtr handle, out long startTime); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_session_id")] + internal static extern int GetSessionId(IntPtr handle, out int sessionId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_hd_icon_state")] + internal static extern int GetHdIconState(IntPtr handle, out int IsHdEnable); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_is_wifi_calling")] + internal static extern int IsWiFiCalling(IntPtr handle, out int isWiFiCalling); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_upgrade_downgrade_state")] + internal static extern int GetUpgradeDowngradeState(IntPtr handle, out int isUpgradeDowngradeEnable); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_is_added_to_conf")] + internal static extern int IsAddedToConference(IntPtr handle, out int isAddedToConf); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_is_remote_on_hold")] + internal static extern int IsRemoteOnHold(IntPtr handle, out int isRemoteOnHold); + [DllImport(Libraries.CallManager, EntryPoint = "cm_conf_call_data_get_call_id")] + internal static extern int GetConfCallId(IntPtr handle, out uint callId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_conf_call_data_get_call_number")] + internal static extern int GetConfCallNumber(IntPtr handle, out string number); + [DllImport(Libraries.CallManager, EntryPoint = "cm_conf_call_data_get_person_id")] + internal static extern int GetConfCallPersonId(IntPtr handle, out int personId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_conf_call_data_get_name_mode")] + internal static extern int GetConfCallNameMode(IntPtr handle, out CallNameMode nameMode); + [DllImport(Libraries.CallManager, EntryPoint = "cm_conf_call_data_free")] + internal static extern int FreeConfCallData(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_lcd_state")] + internal static extern int SetLcdState(LcdControlState state); + [DllImport(Libraries.CallManager, EntryPoint = "cm_start_alert")] + internal static extern int StartAlert(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_set_call_event_cb")] + internal static extern int SetCallEventCb(IntPtr handle, CallEventNotificationCallback callback, IntPtr userData); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unset_call_event_cb")] + internal static extern int UnsetCallEventCb(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_free")] + internal static extern int FreeCallData(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_id")] + internal static extern int GetCallId(IntPtr handle, out uint callId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_direction")] + internal static extern int GetCallDirection(IntPtr handle, out CallDirection direction); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_number")] + internal static extern int GetCallNumber(IntPtr handle, out string number); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_calling_name")] + internal static extern int GetCallingName(IntPtr handle, out string name); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_type")] + internal static extern int GetCallType(IntPtr handle, out CallType type); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_state")] + internal static extern int GetCallState(IntPtr handle, out CallState state); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_call_domain")] + internal static extern int GetCallDomain(IntPtr handle, out CallDomain domain); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_name_mode")] + internal static extern int GetNameMode(IntPtr handle, out CallNameMode nameMode); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_data_get_mt_forwarded")] + internal static extern int IsForwardedCall(IntPtr handle, out bool isForwarded); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_event_data_get_sim_slot")] + internal static extern int GetSimSlot(IntPtr handle, out MultiSimSlot simSlot); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_event_data_get_incom_call")] + internal static extern int GetIncomingCallData(IntPtr handle, out IntPtr incomCall); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_event_data_get_call_id")] + internal static extern int GetEventDataCallId(IntPtr handle, out uint callId); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_event_data_get_active_call")] + internal static extern int GetActiveCall(IntPtr handle, out IntPtr activeCall); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_event_data_get_held_call")] + internal static extern int GetHeldCall(IntPtr handle, out IntPtr heldCall); + [DllImport(Libraries.CallManager, EntryPoint = "cm_call_event_data_get_end_cause")] + internal static extern int GetEndCause(IntPtr handle, out CallEndCause endCause); + [DllImport(Libraries.CallManager, EntryPoint = "cm_hold_call")] + internal static extern int HoldCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_unhold_call")] + internal static extern int UnholdCall(IntPtr handle); + [DllImport(Libraries.CallManager, EntryPoint = "cm_end_call")] + internal static extern int EndCall(IntPtr handle, uint callId, CallReleaseType releaseType); + } +} diff --git a/src/Tizen.CallManager/Interop/Interop.Libraries.cs b/src/Tizen.CallManager/Interop/Interop.Libraries.cs new file mode 100755 index 0000000..1a59b36 --- /dev/null +++ b/src/Tizen.CallManager/Interop/Interop.Libraries.cs @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +internal static partial class Interop +{ + internal static partial class Libraries + { + public const string CallManager = "libcall-manager.so.0"; + public const string Glib = "libglib-2.0.so.0"; + public const string Libc = "libc.so.6"; + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager.csproj b/src/Tizen.CallManager/Tizen.CallManager.csproj new file mode 100644 index 0000000..5ed2f1f --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager.csproj @@ -0,0 +1,14 @@ + + + + + netstandard1.6 + + + + + + + + + diff --git a/src/Tizen.CallManager/Tizen.CallManager.sln b/src/Tizen.CallManager/Tizen.CallManager.sln new file mode 100755 index 0000000..983c733 --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager.sln @@ -0,0 +1,61 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.13 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.CallManager", "Tizen.CallManager.csproj", "{18DF1A45-32B3-4577-84DF-BB3A1537ADC9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{D06D0004-6A5F-4D6C-98C4-ADD3766A867A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{78875590-41AB-4382-B64E-73A50DE0851C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Debug|x64.ActiveCfg = Debug|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Debug|x64.Build.0 = Debug|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Debug|x86.ActiveCfg = Debug|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Debug|x86.Build.0 = Debug|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Release|Any CPU.Build.0 = Release|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Release|x64.ActiveCfg = Release|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Release|x64.Build.0 = Release|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Release|x86.ActiveCfg = Release|Any CPU + {18DF1A45-32B3-4577-84DF-BB3A1537ADC9}.Release|x86.Build.0 = Release|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Debug|x64.ActiveCfg = Debug|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Debug|x64.Build.0 = Debug|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Debug|x86.ActiveCfg = Debug|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Debug|x86.Build.0 = Debug|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Release|Any CPU.Build.0 = Release|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Release|x64.ActiveCfg = Release|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Release|x64.Build.0 = Release|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Release|x86.ActiveCfg = Release|Any CPU + {D06D0004-6A5F-4D6C-98C4-ADD3766A867A}.Release|x86.Build.0 = Release|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Debug|x64.ActiveCfg = Debug|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Debug|x64.Build.0 = Debug|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Debug|x86.ActiveCfg = Debug|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Debug|x86.Build.0 = Debug|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Release|Any CPU.Build.0 = Release|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Release|x64.ActiveCfg = Release|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Release|x64.Build.0 = Release|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Release|x86.ActiveCfg = Release|Any CPU + {78875590-41AB-4382-B64E-73A50DE0851C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Tizen.CallManager/Tizen.CallManager/CallData.cs b/src/Tizen.CallManager/Tizen.CallManager/CallData.cs new file mode 100755 index 0000000..8f7b2da --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CallData.cs @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.CallManager +{ + /// + /// A class which defines the properties of call. + /// + public class CallData + { + internal uint CallId; + internal CallDirection CallDirection; + internal string Number; + internal string Name; + internal CallType CallType; + internal CallState CallState; + internal int Count; + internal bool IsEcc; + internal bool IsVoiceMail; + internal CallDomain CallDomain; + internal int PersonIndex; + internal long CallStartTime; + internal CallNameMode CallNameMode; + internal int SessionIdIms; + internal bool IsHdEnableIms; + internal bool IsWiFiCall; + internal bool IsUpgradeDowngrade; + internal bool IsRemoteHold; + internal bool IsAddedToConf; + internal bool IsForwardedCall; + + internal CallData() + { + } + + /// + /// Gets call id. + /// + public uint Id + { + get + { + return CallId; + } + } + + /// + /// Gets call direction(MO or MT). + /// + public CallDirection Direction + { + get + { + return CallDirection; + } + } + + /// + /// Get the call number. + /// + public string CallNumber + { + get + { + return Number; + } + } + + /// + /// Get the contact name of calling number. + /// + public string CallingName + { + get + { + return Name; + } + } + + /// + /// Get the call type(Voice call or Video call). + /// + public CallType Type + { + get + { + return CallType; + } + } + + /// + /// Get the call state(Incoming, Active, etc). + /// + public CallState State + { + get + { + return CallState; + } + } + + /// + /// Get the member count. + /// + public int MemberCount + { + get + { + return Count; + } + } + + /// + /// Checks if the call is emergency call. + /// + public bool IsEmergency + { + get + { + return IsEcc; + } + } + + /// + /// Checks if the number is voice mail number. + /// + public bool IsVoiceMailNumber + { + get + { + return IsVoiceMail; + } + } + + /// + /// Get the call domain(PS call, CS call, etc). + /// + public CallDomain Domain + { + get + { + return CallDomain; + } + } + + /// + /// Get the person ID. + /// + public int PersonId + { + get + { + return PersonIndex; + } + } + + /// + /// Get the start time of the call. + /// + public long StartTime + { + get + { + return CallStartTime; + } + } + + /// + /// Get the contact name mode. + /// + public CallNameMode Mode + { + get + { + return CallNameMode; + } + } + + /// + /// Get the session ID of the call. + /// + public int SessionId + { + get + { + return SessionIdIms; + } + } + + /// + /// Checks if HD is enabled for calling. + /// + public bool IsHdEnable + { + get + { + return IsHdEnableIms; + } + } + + /// + /// Checks if the call is a WiFi call. + /// + public bool IsWiFiCalling + { + get + { + return IsWiFiCall; + } + } + + /// + /// Checks if upgrade/downgrade is enabled. + /// + public bool IsUpgradeDowngradeEnable + { + get + { + return IsUpgradeDowngrade; + } + } + + /// + /// Checks if the remote call is on hold. + /// + public bool IsRemoteOnHold + { + get + { + return IsRemoteHold; + } + } + + /// + /// Checks if the call is added to conference. + /// + public bool IsAddedToConference + { + get + { + return IsAddedToConf; + } + } + + /// + /// Checks if the incoming call is a forwarded call. + /// + public bool IsMtForwarded + { + get + { + return IsForwardedCall; + } + } + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/CallEventData.cs b/src/Tizen.CallManager/Tizen.CallManager/CallEventData.cs new file mode 100755 index 0000000..dce2d9f --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CallEventData.cs @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.CallManager +{ + /// + /// A class which contains information about call event data. + /// + public class CallEventData + { + internal uint EventId; + internal MultiSimSlot Slot; + internal CallEndCause Cause; + internal CallData Incoming; + internal CallData Active; + internal CallData Held; + internal CallEventData() + { + } + + /// + /// Get the Call id of the number for which Call event has occurred. + /// + public uint Id + { + get + { + return EventId; + } + } + + /// + /// Get the Sim slot type. + /// + public MultiSimSlot SimSlot + { + get + { + return Slot; + } + } + + /// + /// Get call end cause type. + /// + public CallEndCause EndCause + { + get + { + return Cause; + } + } + + /// + /// Get incoming call data. + /// + public CallData IncomingData + { + get + { + return Incoming; + } + } + + /// + /// Get active call data. + /// + public CallData ActiveData + { + get + { + return Active; + } + } + + /// + /// Get the call data for held call. + /// + public CallData HeldData + { + get + { + return Held; + } + } + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/CallManager.cs b/src/Tizen.CallManager/Tizen.CallManager/CallManager.cs new file mode 100755 index 0000000..4a555f8 --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CallManager.cs @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.CallManager +{ + /// + /// A class which manages the use of Call Manager APIs. + /// + public static class CallManager + { + /// + /// Initializes the call manager. + /// + /// An instance of CmClientHandle class to use call manager APIs. + /// http://tizen.org/feature/network.telephony + /// Thrown when telephony feature is not supported. + /// Thrown when method failed due to invalid operation. + public static CmClientHandle InitCm() + { + int ret = Interop.CallManager.InitCm(out IntPtr handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to initialize call manager, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret); + } + + return new CmClientHandle(handle); + } + + /// + /// Deinitializes the Call Manager handle. + /// + /// The Call Manager handle to be deinitialized. + /// Thrown when CmClientHandle is passed as null. + /// Thrown when method failed due to invalid operation. + public static void DeinitCm(CmClientHandle handle) + { + if (handle == null) + { + throw new ArgumentNullException("Call manager client handle is null"); + } + + int ret = Interop.CallManager.DeinitCm(handle._handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to deinitialize call manager, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, handle._handle); + } + + handle._handle = IntPtr.Zero; + } + + /// + /// Sets LCD state for the device display. + /// + /// LCD state to be set. + /// Thrown when method failed due to invalid operation. + public static void SetLcdState(LcdControlState state) + { + int ret = Interop.CallManager.SetLcdState(state); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set LCD state, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret); + } + } + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/CmClientHandle.cs b/src/Tizen.CallManager/Tizen.CallManager/CmClientHandle.cs new file mode 100755 index 0000000..c41dc82 --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CmClientHandle.cs @@ -0,0 +1,1087 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Tizen.CallManager +{ + /// + /// A class which manages call manager events, properties and functions. + /// + public class CmClientHandle + { + internal IntPtr _handle = IntPtr.Zero; + private event EventHandler _callStatusChanged; + private event EventHandler _callMuteStatusChanged; + private event EventHandler _callEvent; + private event EventHandler _dialStatusChanged; + private event EventHandler _audioStateChanged; + private event EventHandler _dtmfIndication; + private event EventHandler _goForeGround; + private event EventHandler _voiceRecordStatusChanged; + + private Interop.CallManager.CallStatusChangedCallback _callStatusChangedCb; + private Interop.CallManager.CallMuteStatusChangedCallback _callMuteStatusChangedCb; + private Interop.CallManager.CallEventNotificationCallback _callEventCb; + private Interop.CallManager.DialStatusChangedCallback _dialStatusChangedCb; + private Interop.CallManager.AudioStateChangedCallback _audioStateChangedCb; + private Interop.CallManager.DtmfIndicationChangedCallback _dtmfIndicationChangedCb; + private Interop.CallManager.GoForegroundCallback _goForeGroundCb; + private Interop.CallManager.VoiceRecordStatusChangedCallback _voiceRecordStatusChangedCb; + + internal CmClientHandle(IntPtr handle) + { + _handle = handle; + } + + /// + /// This event is raised when call status changes. + /// + public event EventHandler CallStatusChanged + { + add + { + if (_callStatusChanged == null) + { + RegisterCallStatusChangedEvent(); + } + + _callStatusChanged += value; + } + + remove + { + _callStatusChanged -= value; + if (_callStatusChanged == null) + { + UnregisterCallStatusChangedEvent(); + } + } + } + + /// + /// This event is raised when the mute status changes. + /// + public event EventHandler CallMuteStatusChanged + { + add + { + if (_callMuteStatusChanged == null) + { + RegisterCallMuteStatusChangedEvent(); + } + + _callMuteStatusChanged += value; + } + + remove + { + _callMuteStatusChanged -= value; + if (_callMuteStatusChanged == null) + { + UnregisterCallMuteStatusChangedEvent(); + } + } + } + + /// + /// This event is raised when call events change. + /// + public event EventHandler CallEvent + { + add + { + if (_callEvent == null) + { + RegisterCallEventNotification(); + } + + _callEvent += value; + } + + remove + { + _callEvent -= value; + if (_callEvent == null) + { + UnregisterCallEventNotification(); + } + } + } + + /// + /// This event is raised when dial status changes. + /// + public event EventHandler DialStatusChanged + { + add + { + if (_dialStatusChanged == null) + { + RegisterDialStatusEvent(); + } + + _dialStatusChanged += value; + } + + remove + { + _dialStatusChanged -= value; + if (_dialStatusChanged == null) + { + UnregisterDialStatusEvent(); + } + } + } + + /// + /// This event is raised when audio status changes. + /// + public event EventHandler AudioStateChanged + { + add + { + if (_audioStateChanged == null) + { + RegisterAudioStateChangedEvent(); + } + + _audioStateChanged += value; + } + + remove + { + _audioStateChanged -= value; + if (_audioStateChanged == null) + { + UnregisterAudioStateChangedEvent(); + } + } + } + + /// + /// This event is raised during DTMF indication. + /// + public event EventHandler DtmfIndication + { + add + { + if (_dtmfIndication == null) + { + RegisterDtmfIndicationEvent(); + } + + _dtmfIndication += value; + } + + remove + { + _dtmfIndication -= value; + if (_dtmfIndication == null) + { + UnregisterDtmfIndicationEvent(); + } + } + } + + /// + /// This event is raised when call comes to foreground. + /// + public event EventHandler GoForeground + { + add + { + if (_goForeGround == null) + { + RegisterGoForegroundEvent(); + } + + _goForeGround += value; + } + + remove + { + _goForeGround -= value; + if (_goForeGround == null) + { + UnregisterGoForegroundEvent(); + } + } + } + + /// + /// This event is raised when voice record status is changed. + /// + public event EventHandler VoiceRecordStatusChanged + { + add + { + if (_voiceRecordStatusChanged == null) + { + RegisterVoiceRecordStatusEvent(); + } + + _voiceRecordStatusChanged += value; + } + + remove + { + _voiceRecordStatusChanged -= value; + if (_voiceRecordStatusChanged == null) + { + UnregisterVoiceRecordStatusEvent(); + } + } + } + + private void RegisterCallStatusChangedEvent() + { + _callStatusChangedCb = (CallStatus status, string number, IntPtr userData) => + { + _callStatusChanged?.Invoke(null, new CallStatusChangedEventArgs(status, number)); + }; + int ret = Interop.CallManager.SetCallStatusCallback(_handle, _callStatusChangedCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set call status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterCallStatusChangedEvent() + { + int ret = Interop.CallManager.UnsetCallstatusCallback(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset call status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterCallMuteStatusChangedEvent() + { + _callMuteStatusChangedCb = (CallMuteStatus muteStatus, IntPtr userData) => + { + _callMuteStatusChanged?.Invoke(null, new CallMuteStatusChangedEventArgs(muteStatus)); + }; + int ret = Interop.CallManager.SetCallMuteStatusCallback(_handle, _callMuteStatusChangedCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set call mute status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterCallMuteStatusChangedEvent() + { + int ret = Interop.CallManager.UnsetCallMuteStatusCallback(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset call mute status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterCallEventNotification() + { + _callEventCb = (CallEvent callEvent, IntPtr eventData, IntPtr userData) => + { + _callEvent?.Invoke(null, new CallEventEventArgs(callEvent, CmUtility.GetCallEventData(eventData))); + }; + int ret = Interop.CallManager.SetCallEventCb(_handle, _callEventCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set call event notification callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterCallEventNotification() + { + int ret = Interop.CallManager.UnsetCallEventCb(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset call event notification callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterDialStatusEvent() + { + _dialStatusChangedCb = (DialStatus status, IntPtr userData) => + { + _dialStatusChanged?.Invoke(null, new DialStatusEventArgs(status)); + }; + int ret = Interop.CallManager.SetDialStatusCb(_handle, _dialStatusChangedCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set dial status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterDialStatusEvent() + { + int ret = Interop.CallManager.UnsetDialStatusCb(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset dial status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterAudioStateChangedEvent() + { + _audioStateChangedCb = (AudioState state, IntPtr userData) => + { + _audioStateChanged?.Invoke(null, new AudioStatusChangedEventArgs(state)); + }; + int ret = Interop.CallManager.SetAudioStateChangedCb(_handle, _audioStateChangedCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set audio state changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterAudioStateChangedEvent() + { + int ret = Interop.CallManager.UnsetAudioStateChangedCb(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset audio state changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterDtmfIndicationEvent() + { + _dtmfIndicationChangedCb = (DtmfIndication indiType, string number, IntPtr userData) => + { + _dtmfIndication?.Invoke(null, new DtmfIndicationEventArgs(indiType, number)); + }; + int ret = Interop.CallManager.SetDtmfIndicationCb(_handle, _dtmfIndicationChangedCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set DTMF indication changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterDtmfIndicationEvent() + { + int ret = Interop.CallManager.UnsetDtmfIndicationCb(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset DTMF indication changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterGoForegroundEvent() + { + _goForeGroundCb = (IntPtr userData) => + { + _goForeGround?.Invoke(null, EventArgs.Empty); + }; + int ret = Interop.CallManager.SetForegroundCb(_handle, _goForeGroundCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set go foreground callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterGoForegroundEvent() + { + int ret = Interop.CallManager.UnsetForegroundCb(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset go foreground callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void RegisterVoiceRecordStatusEvent() + { + _voiceRecordStatusChangedCb = (VrStatus vrStatus, VrStatusExtraType extraType, IntPtr userData) => + { + _voiceRecordStatusChanged?.Invoke(null, new VoiceRecordStatusEventArgs(vrStatus, extraType)); + }; + int ret = Interop.CallManager.SetVoiceRecordStatusCb(_handle, _voiceRecordStatusChangedCb, IntPtr.Zero); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set voice record status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + private void UnregisterVoiceRecordStatusEvent() + { + int ret = Interop.CallManager.UnsetVoiceRecordStatusCb(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unset voice record status changed callback, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + public CallStatus CallStatus + { + get + { + int ret = Interop.CallManager.GetStatus(_handle, out CallStatus status); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call status, Error: " + (CmError)ret); + return default(CallStatus); + } + + return status; + } + } + + /// + /// Gets the mute status. + /// + public CallMuteStatus CallMuteStatus + { + get + { + int ret = Interop.CallManager.GetMuteStatus(_handle, out CallMuteStatus status); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call mute status, Error: " + (CmError)ret); + return default(CallMuteStatus); + } + + return status; + } + } + + /// + /// Gets the audio state. + /// + public AudioState AudioState + { + get + { + int ret = Interop.CallManager.GetAudioState(_handle, out AudioState state); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get audio state, Error: " + (CmError)ret); + return default(AudioState); + } + + return state; + } + } + + /// + /// Gets the list of call data. + /// + public IEnumerable AllCalls + { + get + { + int ret = Interop.CallManager.GetAllCallList(_handle, out IntPtr list); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get all call list, Error: " + (CmError)ret); + return null; + } + + List callList = new List(); + int offset = 0; + IntPtr data = Marshal.ReadIntPtr(list, offset); + if (data != IntPtr.Zero) + { + do + { + offset += Marshal.SizeOf(data); + callList.Add(CmUtility.GetCallData(data)); + Interop.CallManager.FreeCallData(data); + data = IntPtr.Zero; + } + + while ((data = Marshal.ReadIntPtr(list, offset)) != IntPtr.Zero); + } + + return callList; + } + } + + /// + /// Gets the list of conference call data. + /// + public IEnumerable AllConferenceCalls + { + get + { + int ret = Interop.CallManager.GetConferenceCallList(_handle, out IntPtr list); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get conference call list, Error: " + (CmError)ret); + return null; + } + + List confList = new List(); + int offset = 0; + IntPtr data = Marshal.ReadIntPtr(list, offset); + if (data != IntPtr.Zero) + { + do + { + offset += Marshal.SizeOf(data); + confList.Add(CmUtility.GetConfCallData(data)); + Interop.CallManager.FreeConfCallData(data); + data = IntPtr.Zero; + } + + while ((data = Marshal.ReadIntPtr(list, offset)) != IntPtr.Zero); + } + + return confList; + } + } + + /// + /// Rejects the incoming call. + /// + /// partner + /// http://developer.samsung.com/tizen/privilege/call.reject + /// Thrown when privilege access is denied. + /// Thrown when method failed due to invalid operation. + public void RejectCall() + { + int ret = Interop.CallManager.RejectCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to reject call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.reject"); + } + } + + /// + /// Starts incoming call alert ringtone. + /// + /// Thrown when privilege access is denied. + /// Thrown when method failed due to invalid operation. + public void StartAlert() + { + int ret = Interop.CallManager.StartAlert(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to start incoming call alert, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Stops incoming call alert ringtone. + /// + /// partner + /// http://developer.samsung.com/tizen/privilege/call.reject + /// Thrown when privilege access is denied. + /// Thrown when method failed due to invalid operation. + public void StopAlert() + { + int ret = Interop.CallManager.StopAlert(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to stop incoming call alert, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.reject"); + } + } + + /// + /// Enables call recovery. + /// + /// App ID to be recovered. + /// Thrown appId is passed as null. + /// Thrown when method failed due to invalid operation. + public void EnableRecovery(string appId) + { + if (appId == null) + { + throw new ArgumentNullException("App ID is null"); + } + + int ret = Interop.CallManager.EnableRecovery(_handle, appId); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to enable recovery, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Dials a call. + /// + /// Calling number to be dialed. + /// Type of the call to be dialed. + /// Multi sim slot type in which the call is dialed. + /// Thrown when privilege access is denied. + /// Thrown number is passed as null. + /// Thrown when method failed due to invalid operation. + public void DialCall(string number, CallType type, MultiSimSlot slot) + { + if (number == null) + { + throw new ArgumentNullException("Calling number is null"); + } + + int ret = Interop.CallManager.DialCall(_handle, number, type, slot); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to dial call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Swaps the calls. + /// + /// Thrown when method failed due to invalid operation. + public void SwapCall() + { + int ret = Interop.CallManager.SwapCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to swap call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Joins a call with another. + /// + /// Thrown when method failed due to invalid operation. + public void JoinCall() + { + int ret = Interop.CallManager.JoinCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to join call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Splits a call. + /// + /// Call id to be splitted. + /// Thrown when method failed due to invalid operation. + public void SplitCall(uint id) + { + int ret = Interop.CallManager.SplitCall(_handle, id); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to split call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Transfers a call. + /// + /// Thrown when method failed due to invalid operation. + public void TransferCall() + { + int ret = Interop.CallManager.TransferCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to transfer call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Accepts MT ViLTE call as VoLTE. + /// + /// Call answer type. + /// Call type. + /// Thrown when method failed due to invalid operation. + public void AnswerCallEx(CallAnswerType answerType, CallType type) + { + int ret = Interop.CallManager.AnswerCallEx(_handle, answerType, type); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to answer call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Answers an incoming call. + /// + /// Call answer type. + /// Thrown when method failed due to invalid operation. + public void AnswerCall(CallAnswerType answerType) + { + int ret = Interop.CallManager.AnswerCall(_handle, answerType); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to answer call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Upgrades a call. + /// + /// Thrown when method failed due to invalid operation. + public void UpgradeCall() + { + int ret = Interop.CallManager.UpgradeCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to upgrade call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Downgrades a call. + /// + /// Thrown when method failed due to invalid operation. + public void DowngradeCall() + { + int ret = Interop.CallManager.DowngradeCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to downgrade call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Confirms upgrade call request. + /// + /// Upgrade response type. + /// Thrown when method failed due to invalid operation. + public void ConfirmUpgradeCall(CallUpgradeResponseType response) + { + int ret = Interop.CallManager.ConfirmUpgradeCall(_handle, response); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to confirm upgrade call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sets the speaker on/off. + /// + /// Status of the speaker to be set. + /// Thrown when method failed due to invalid operation. + public void ManageSpeaker(FeatureStatus status) + { + int ret = -1; + if (status == FeatureStatus.Off) + { + ret = Interop.CallManager.SpeakerOff(_handle); + } + + else if (status == FeatureStatus.On) + { + ret = Interop.CallManager.SpeakerOn(_handle); + } + + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to manage speaker, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sets the bluetooth feature on/off. + /// + /// Status of the bluetooth to be set. + /// Thrown when method failed due to invalid operation. + public void ManageBluetooth(FeatureStatus status) + { + int ret = -1; + if (status == FeatureStatus.Off) + { + ret = Interop.CallManager.BluetoothOff(_handle); + } + + else if (status == FeatureStatus.On) + { + ret = Interop.CallManager.BluetoothOn(_handle); + } + + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to manage bluetooth, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sets extra volume if needed. + /// + /// Boolean value to indicate if the call is set to have extra volume. + /// Thrown when method failed due to invalid operation. + public void SetExtraVolume(bool isExtraVolume) + { + int ret = Interop.CallManager.SetExtraVolume(_handle, isExtraVolume); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set extra volume, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sets the noise reduction feature during call. + /// + /// Boolean value to indicate whether the call needs noise reduction. + /// Thrown when method failed due to invalid operation. + public void SetNoiseReduction(bool isNoiceReduction) + { + int ret = Interop.CallManager.SetNoiseReduction(_handle, isNoiceReduction); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set noise reduction, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sets the mute state of the call. + /// + /// Mute state to be set. + /// Thrown when method failed due to invalid operation. + public void SetMuteState(bool isMuteState) + { + int ret = Interop.CallManager.SetMuteState(_handle, isMuteState); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set mute state, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Starts sending signal through DTMF digit. + /// + /// DTMF digit to be pressed on the phone. + /// Thrown when method failed due to invalid parameter. + /// Thrown when method failed due to invalid operation. + public void StartDtmf(byte dtmfDigit) + { + int ret = Interop.CallManager.StartDtmf(_handle, dtmfDigit); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to start DTMF, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Stops sending DTMF signal. + /// + /// Thrown when method failed due to invalid operation. + public void StopDtmf() + { + int ret = Interop.CallManager.StopDtmf(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to stop DTMF, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sends signal through DTMF digits. + /// + /// DTMF digits. + /// Thrown when dtmfDigits is passed as null. + /// Thrown when method failed due to invalid operation. + public void BurstDtmf(string dtmfDigits) + { + if (dtmfDigits == null) + { + throw new ArgumentNullException("DTMF digits is null"); + } + + int ret = Interop.CallManager.BurstDtmf(_handle, dtmfDigits); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to burst DTMF, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sends DTMF response. + /// + /// DTMF response type. + /// Thrown when method failed due to invalid operation. + public void SendDtmfResponse(DtmfResponseType response) + { + int ret = Interop.CallManager.SendDtmfResponse(_handle, response); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to send DTMF response, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Activates call manager UI. + /// + /// Thrown when method failed due to invalid operation. + public void ActivateUi() + { + int ret = Interop.CallManager.ActivateUi(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to activate UI, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Sets device LCD time out. + /// + /// LCD timeout to be set. + /// Thrown when method failed due to invalid operation. + public void SetLcdTimeout(LcdTimeOut timeout) + { + int ret = Interop.CallManager.SetLcdTimeOut(_handle, timeout); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to set LCD timeout, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Starts voice recording. + /// + /// Call number. + /// Thrown when number is passed as null. + /// Thrown when method failed due to invalid operation. + public void StartVoiceRecord(string number) + { + if (number == null) + { + throw new ArgumentNullException("Call number is null"); + } + + int ret = Interop.CallManager.StartVoiceRecord(_handle, number); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to start voice record, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Stops voice record. + /// + /// Thrown when method failed due to invalid operation. + public void StopVoiceRecord() + { + int ret = Interop.CallManager.StopVoiceRecord(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to stop voice record, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + } + + /// + /// Gets all current call data. + /// + /// Incoming calldata instance to be filled. + /// Active calldata instance to be filled. + /// Held calldata instance to be filled. + /// Thrown when method failed due to invalid operation. + public void GetAllCallData(out CallData incoming, out CallData active, out CallData held) + { + int ret = Interop.CallManager.GetAllCallData(_handle, out IntPtr incomingCall, out IntPtr activeCall, out IntPtr heldCall); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get all call data, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle); + } + + incoming = CmUtility.GetCallData(incomingCall); + active = CmUtility.GetCallData(activeCall); + held = CmUtility.GetCallData(heldCall); + } + + /// + /// Holds the active call. + /// + /// platform + /// http://developer.samsung.com/tizen/privilege/call.admin + /// Thrown when privilege access is denied. + /// Thrown when method failed due to invalid operation. + public void HoldCall() + { + int ret = Interop.CallManager.HoldCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to hold call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin"); + } + } + + /// + /// Unholds the active call. + /// + /// platform + /// http://developer.samsung.com/tizen/privilege/call.admin + /// Thrown when privilege access is denied. + /// Thrown when method failed due to invalid operation. + public void UnholdCall() + { + int ret = Interop.CallManager.UnholdCall(_handle); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to unhold call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin"); + } + } + + /// + /// Ends ongoing call. + /// + /// ID of the call which is to be ended. + /// Call release type. + /// platform + /// http://developer.samsung.com/tizen/privilege/call.admin + /// Thrown when privilege access is denied. + /// Thrown when method failed due to invalid operation. + public void EndCall(uint id, CallReleaseType type) + { + int ret = Interop.CallManager.EndCall(_handle, id, type); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to end call, Error: " + (CmError)ret); + CmUtility.ThrowCmException(ret, _handle, "http://developer.samsung.com/tizen/privilege/call.admin"); + } + } + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/CmEnumerations.cs b/src/Tizen.CallManager/Tizen.CallManager/CmEnumerations.cs new file mode 100755 index 0000000..a7965dd --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CmEnumerations.cs @@ -0,0 +1,692 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.CallManager +{ + /// + /// Enumeration for Call status. + /// + public enum CallStatus + { + /// + /// Call is in idle state. + /// + Idle, + /// + /// A new call arrived and is ringing or waiting. + /// + Ringing, + /// + /// At least one call exist that is in dialing, alerting, active, on hold state. + /// + OffHook, + /// + /// Max state. + /// + Max + } + + /// + /// Enumeration for Mute status. + /// + public enum CallMuteStatus + { + /// + /// Mute state is off. + /// + Off, + /// + /// Mute state is on. + /// + On, + /// + /// Max status. + /// + Max + } + + /// + /// Enumeration for call dial status. + /// + public enum DialStatus + { + /// + /// Dial status is success. + /// + Success = 0, + /// + /// Dial status is cancel. + /// + Cancel, + /// + /// Dial status is fail. + /// + Fail, + /// + /// Dial status is fail SS. + /// + FailSS, + /// + /// Dial status is fail FDN. + /// + FailFdn, + /// + /// Dial status is fail flight mode. + /// + FailFlightMode + } + + /// + /// Enumeration for DTMF indication type. + /// + public enum DtmfIndication + { + /// + /// DTMF indication type is idle. + /// + Idle = 0, + /// + /// DTMF indication type is progressing. + /// + Progressing, + /// + /// DTMF indication type is wait. + /// + Wait + } + + /// + /// Enumeration for audio state type. + /// + public enum AudioState + { + /// + /// None. + /// + None, + /// + /// System LoudSpeaker path. + /// + Speaker, + /// + /// System Receiver. + /// + Receiver, + /// + /// Earjack path. + /// + EarJack, + /// + /// System BT Headset path. + /// + BTHeadset + } + + /// + /// Enumeration for video record status. + /// + public enum VrStatus + { + /// + /// Video recording is started. + /// + Started = 0, + /// + /// Video recording is stopped. + /// + Stopped + } + + /// + /// Enumeration for Video record status extra type. + /// + public enum VrStatusExtraType + { + /// + /// Start. + /// + Start = 0x00, + /// + /// Normal recording. + /// + StartNormal, + /// + /// Answering message. + /// + StartAnswerMessage, + /// + /// Start max. + /// + StartMax = 0x0f, + /// + /// Stop. + /// + Stop = 0x10, + /// + /// Stop by normal. + /// + StopByNormal, + /// + /// Stop by max size. + /// + StopByMaxSize, + /// + /// Stop by no free space. + /// + StopByNoFreeSpace, + /// + /// Stop by time limit. + /// + StopByTimeLimit, + /// + /// Error. + /// + StopError, + /// + /// Stop by max. + /// + StopMax = 0x1f + } + + /// + /// Enumeration for call type. + /// + public enum CallType + { + /// + /// Voice call type. + /// + Voice, + /// + /// Video call type. + /// + Video, + /// + /// Invalid call type. + /// + Invalid + } + + /// + /// Enumeration for sim slot type. + /// + public enum MultiSimSlot + { + /// + /// Sim slot 1. + /// + Slot1, + /// + /// Sim slot 2. + /// + Slot2, + /// + /// Follow system configuration. + /// + Default + } + + /// + /// Enumeration for call answer types for accepting the incoming call. + /// + public enum CallAnswerType + { + /// + /// Only single call exist, Accept the Incoming call. + /// + Normal = 0, + /// + /// Put the active call on hold and accepts the call. + /// + HoldActiveAndAccept, + /// + /// Releases the active call and accept the call. + /// + ReleaseActiveAndAccept, + /// + /// Releases the held call and accept the call. + /// + ReleaseHoldAndAccept, + /// + /// Releases all calls and accept the call. + /// + ReleaseAllAndAccept + } + + /// + /// Enumeration for call upgrade response type while receiving upgrade request. + /// + public enum CallUpgradeResponseType + { + /// + /// Accept incoming upgrade request. + /// + Accept, + /// + /// Reject Incoming upgrade request. + /// + Reject + } + + /// + /// Enumeration for feature(speaker/bluetooth) status. + /// + public enum FeatureStatus + { + /// + /// On. + /// + On, + /// + /// Off. + /// + Off + } + + /// + /// Enumeration for DTMF response type. + /// + public enum DtmfResponseType + { + /// + /// Cancel. + /// + Cancel = 0, + /// + /// Continue. + /// + Continue + } + + /// + /// Enumeration for LCD time out. + /// + public enum LcdTimeOut + { + /// + /// Set. + /// + Set = 1, + /// + /// Unset. + /// + Unset, + /// + /// After lock-screen comes in Connected state LCD goes to OFF in 5 secs. + /// + LockscreenSet, + /// + /// When Keypad is ON, LCD goes to DIM in 3 secs then goes to OFF in 5 secs. + /// + KeypadSet, + /// + /// Default. + /// + Default + } + + /// + /// Enumeration for contact name mode. + /// + public enum CallNameMode + { + /// + /// None. + /// + None, + /// + /// Unknown. + /// + Unknown, + /// + /// Private. + /// + Private, + /// + /// Payphone. + /// + PayPhone + } + + /// + /// Enumeration for LCD control state. + /// + public enum LcdControlState + { + /// + /// Off. + /// + Off = 1, + /// + /// On. + /// + On, + /// + /// On lock. + /// + OnLock, + /// + /// On unlock. + /// + OnUnlock, + /// + /// Off sleep lock. + /// + OffSleepLock, + /// + /// Off sleep unlock. + /// + OffSleepUnlock + } + + /// + /// Enumeration for call event type. + /// + public enum CallEvent + { + /// + /// Call Idle event. + /// + Idle = 0, + /// + /// Call Dialling event. + /// + Dialing, + /// + /// Call Active event. + /// + Active, + /// + /// Call Held event. + /// + Held, + /// + /// Call Alert event. + /// + Alert, + /// + /// Call Incoming event. + /// + Incoming, + /// + /// Call Waiting event. + /// + Waiting, + /// + /// Call Join event. + /// + Join, + /// + /// Call Split event. + /// + Split, + /// + /// Call Swapped event. + /// + Swapped, + /// + /// Call Retrieved event. + /// + Retrieved, + /// + /// Sat call control event. + /// + SatCallControl, + /// + /// Call upgrade request event. + /// + UpgradeRequest, + /// + /// Call downgraded event. + /// + Downgraded, + /// + /// Call upgrade success event. + /// + UpgradeSuccess, + /// + /// Call upgrade failure event. + /// + UpgradeFailure, + /// + /// Call downgrade success event. + /// + DowngradeSuccess, + /// + /// Call downgrade failure event. + /// + DowngradeFailure, + /// + /// Call confirm upgrade success event. + /// + ConfirmUpgradeSuccess, + /// + /// Call confirm upgrade failure event. + /// + ConfirmUpgradeFailure, + /// + /// VoWiFi ~ LTE hand-over update event. + /// + VoWiFiLteHandoverUpdate + } + + /// + /// Enumeration for call direction + /// + public enum CallDirection + { + /// + /// MO call. + /// + MO, + /// + /// MT call. + /// + MT + } + + /// + /// Enumeration for the call state. + /// + public enum CallState + { + /// + /// Call is in idle state. + /// + Idle, + /// + /// Call is in connected and conversation state. + /// + Active, + /// + /// Call is in held state. + /// + Held, + /// + /// Call is in dialing state. + /// + Dialing, + /// + /// Call is in alerting state. + /// + Alert, + /// + /// Call is in incoming state. + /// + Incoming, + /// + /// Call is in answered state, and waiting for connected indication event. + /// + Waiting + } + + /// + /// Enumeration for call domain. + /// + public enum CallDomain + { + /// + /// CS call domain. + /// + Cs, + /// + /// PS call domain. + /// + Ps, + /// + /// Wearable call through BT handsfree profile. + /// + Hfp + } + + /// + /// Enumeration for call end cause type. + /// + public enum CallEndCause + { + /// + /// Call ended. + /// + Ended, + /// + /// Call disconnected. + /// + Disconnected, + /// + /// Service not allowed. + /// + ServiceNotAllowed, + /// + /// Call barred. + /// + Barred, + /// + /// No service. + /// + NoService, + /// + /// Network busy. + /// + NwBusy, + /// + /// Network failed. + /// + NwFailed, + /// + /// No answer from other party. + /// + NoAnswer, + /// + /// No credit available. + /// + NoCredit, + /// + /// Call rejected. + /// + Rejected, + /// + /// User busy. + /// + UserBusy, + /// + /// Wrong group. + /// + WrongGroup, + /// + /// Call not allowed. + /// + NotAllowed, + /// + /// Tapi error. + /// + TapiError, + /// + /// Call failed. + /// + Failed, + /// + /// User not responding. + /// + NoUserResponding, + /// + /// User alerting no answer. + /// + UserAlertingNoAnswer, + /// + /// Circuit Channel Unavailable,Network is out of Order,Switching equipment congestion,Temporary Failure. + /// + ServiceTempUnavailable, + /// + /// Called Party Rejects the Call. + /// + UserUnavailable, + /// + /// Entered number is invalid or incomplete. + /// + InvalidNumberFormat, + /// + /// Entered number has been changed. + /// + NumberChanged, + /// + /// Unassigned/Unallocated number. + /// + UnassignedNumber, + /// + /// Called Party does not respond. + /// + UserDoesNotRespond, + /// + /// IMEI rejected. + /// + ImeiRejected, + /// + /// FDN number only. + /// + FixedDialingNumberOnly, + /// + /// SAT call control reject. + /// + SatCallControlReject, + /// + /// This number cannot receive video calls. + /// + CannotReceiveVideoCall + } + + /// + /// Enumeration for call release type. + /// + public enum CallReleaseType + { + /// + /// Release call using given call handle. + /// + ByCallHandle = 0, + /// + /// Release all Calls. + /// + AllCalls, + /// + /// Releases all hold calls. + /// + AllHoldCalls, + /// + /// Releases all active calls. + /// + AllActiveCalls + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/CmEventArgs.cs b/src/Tizen.CallManager/Tizen.CallManager/CmEventArgs.cs new file mode 100755 index 0000000..77a69fd --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CmEventArgs.cs @@ -0,0 +1,240 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.CallManager +{ + /// + /// An extended EventArgs class which contains information about DTMF indication. + /// + public class DtmfIndicationEventArgs : EventArgs + { + private DtmfIndication _indication; + private string _dtmfNumber; + + internal DtmfIndicationEventArgs(DtmfIndication indication, string dtmfNumber) + { + _indication = indication; + _dtmfNumber = dtmfNumber; + } + + /// + /// DTMF indication. + /// + public DtmfIndication Indication + { + get + { + return _indication; + } + } + + /// + /// DTMF number. + /// + public string DtmfNumber + { + get + { + return _dtmfNumber; + } + } + } + + /// + /// An extended EventArgs class which contains changed audio status. + /// + public class AudioStatusChangedEventArgs : EventArgs + { + private AudioState _state; + + internal AudioStatusChangedEventArgs(AudioState state) + { + _state = state; + } + + /// + /// Audio state. + /// + public AudioState State + { + get + { + return _state; + } + } + } + + /// + /// An extended EventArgs class which contains changed voice record status. + /// + public class VoiceRecordStatusEventArgs : EventArgs + { + private VrStatus _status; + private VrStatusExtraType _extraType; + + internal VoiceRecordStatusEventArgs(VrStatus status, VrStatusExtraType extraType) + { + _status = status; + _extraType = extraType; + } + + /// + /// Voice record status. + /// + public VrStatus Status + { + get + { + return _status; + } + } + + /// + /// Voice record status extra type. + /// + public VrStatusExtraType ExtraType + { + get + { + return _extraType; + } + } + } + + /// + /// An extended EventArgs class which contains changed call mute status. + /// + public class CallMuteStatusChangedEventArgs : EventArgs + { + private CallMuteStatus _Status; + + internal CallMuteStatusChangedEventArgs(CallMuteStatus status) + { + _Status = status; + } + + /// + /// Call mute status. + /// + public CallMuteStatus Status + { + get + { + return _Status; + } + } + } + + /// + /// An extended EventArgs class which contains changed call status. + /// + public class CallStatusChangedEventArgs : EventArgs + { + private CallStatus _status; + private string _callNumber; + + internal CallStatusChangedEventArgs(CallStatus status, string number) + { + _status = status; + _callNumber = number; + } + + /// + /// Call status. + /// + public CallStatus Status + { + get + { + return _status; + } + } + + /// + /// Call number. + /// + public string CallNumber + { + get + { + return _callNumber; + } + } + } + + /// + /// An extended EventArgs class which contains changed dial status. + /// + public class DialStatusEventArgs : EventArgs + { + private DialStatus _status; + + internal DialStatusEventArgs(DialStatus status) + { + _status = status; + } + + /// + /// Dial status. + /// + public DialStatus Status + { + get + { + return _status; + } + } + } + + /// + /// An extended EventArgs class which contains changed call event. + /// + public class CallEventEventArgs : EventArgs + { + private CallEvent _event; + private CallEventData _eventData; + + internal CallEventEventArgs(CallEvent callEvent, CallEventData data) + { + _event = callEvent; + _eventData = data; + } + + /// + /// Call event. + /// + public CallEvent Event + { + get + { + return _event; + } + } + + /// + /// Call event data. + /// + public CallEventData EventData + { + get + { + return _eventData; + } + } + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/CmUtility.cs b/src/Tizen.CallManager/Tizen.CallManager/CmUtility.cs new file mode 100755 index 0000000..91d2c49 --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/CmUtility.cs @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using Tizen.Internals.Errors; + +namespace Tizen.CallManager +{ + internal enum CmError + { + None = ErrorCode.None, + OutOfMemory = ErrorCode.OutOfMemory, + InvalidParameter = ErrorCode.InvalidParameter, + PermissionDenied = ErrorCode.PermissionDenied, + NotSupported = ErrorCode.NotSupported, + NotRegistered = -0x00000000 | 0x01, + AlreadyRegistered = -0x00000000 | 0x02, + OperationFailed = -0x00000000 | 0x03, + InvalidState = -0x00000000 | 0x04 + } + + internal static class CmUtility + { + internal const string LogTag = "Tizen.CallManager"; + + internal static CallData GetCallData(IntPtr handle) + { + CallData data = new CallData(); + int ret = Interop.CallManager.GetCallId(handle, out uint id); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call ID from call data, Error: " + (CmError)ret); + } + + else + { + data.CallId = id; + } + + ret = Interop.CallManager.GetCallDirection(handle, out CallDirection direction); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call direction from call data, Error: " + (CmError)ret); + } + + else + { + data.CallDirection = direction; + } + + ret = Interop.CallManager.GetCallNumber(handle, out string number); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call number from call data, Error: " + (CmError)ret); + } + + else + { + data.Number = number; + } + + ret = Interop.CallManager.GetCallingName(handle, out string name); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get calling name from call data, Error: " + (CmError)ret); + } + + else + { + data.Name = name; + } + + ret = Interop.CallManager.GetCallType(handle, out CallType type); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call type from call data, Error: " + (CmError)ret); + } + + else + { + data.CallType = type; + } + + ret = Interop.CallManager.GetCallState(handle, out CallState state); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call state from call data, Error: " + (CmError)ret); + } + + else + { + data.CallState = state; + } + + ret = Interop.CallManager.GetCallMemberCount(handle, out int count); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call member count from call data, Error: " + (CmError)ret); + } + + else + { + data.Count = count; + } + + ret = Interop.CallManager.IsEmergencyCall(handle, out bool isEmergency); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to check if the call is emergency from call data, Error: " + (CmError)ret); + } + + else + { + data.IsEcc = isEmergency; + } + + ret = Interop.CallManager.IsVoiceMailNumber(handle, out bool isVoiceMail); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to check if the number is voicemail number from call data, Error: " + (CmError)ret); + } + + else + { + data.IsVoiceMail = isVoiceMail; + } + + ret = Interop.CallManager.GetCallDomain(handle, out CallDomain domain); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get call domain from call data, Error: " + (CmError)ret); + } + + else + { + data.CallDomain = domain; + } + + ret = Interop.CallManager.GetPersonId(handle, out int personId); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get person ID from call data, Error: " + (CmError)ret); + } + + else + { + data.PersonIndex = personId; + } + + ret = Interop.CallManager.GetStartTime(handle, out long startTime); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get start time from call data, Error: " + (CmError)ret); + } + + else + { + data.CallStartTime = startTime; + } + + ret = Interop.CallManager.GetNameMode(handle, out CallNameMode nameMode); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get name mode from call data, Error: " + (CmError)ret); + } + + else + { + data.CallNameMode = nameMode; + } + + ret = Interop.CallManager.GetSessionId(handle, out int sessionId); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get session ID from call data, Error: " + (CmError)ret); + } + + else + { + data.SessionIdIms = sessionId; + } + + ret = Interop.CallManager.GetHdIconState(handle, out int isHdEnable); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get HD icon state from call data, Error: " + (CmError)ret); + } + + else + { + data.IsHdEnableIms = (isHdEnable == 1) ? true : false; + } + + ret = Interop.CallManager.IsWiFiCalling(handle, out int isWiFiCalling); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to identify WiFi calling from call data, Error: " + (CmError)ret); + } + + else + { + data.IsWiFiCall = (isWiFiCalling == 1) ? true : false; + } + + ret = Interop.CallManager.GetUpgradeDowngradeState(handle, out int isEnable); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get updagrade downgrade state from call data, Error: " + (CmError)ret); + } + + else + { + data.IsUpgradeDowngrade = (isEnable == 1) ? true : false; + } + + ret = Interop.CallManager.IsRemoteOnHold(handle, out int isHold); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get remote on hold state from call data, Error: " + (CmError)ret); + } + + else + { + data.IsRemoteHold = (isHold == 1) ? true : false; + } + + ret = Interop.CallManager.IsAddedToConference(handle, out int isAdded); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to check if the call is in conf state from call data, Error: " + (CmError)ret); + } + + else + { + data.IsAddedToConf = (isAdded == 1) ? true : false; + } + + ret = Interop.CallManager.IsForwardedCall(handle, out bool isForwarded); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to check if the call is forwarded call from call data, Error: " + (CmError)ret); + } + + else + { + data.IsForwardedCall = isForwarded; + } + + return data; + } + + internal static ConferenceCallData GetConfCallData(IntPtr handle) + { + ConferenceCallData confData = new ConferenceCallData(); + int ret = Interop.CallManager.GetConfCallId(handle, out uint callId); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get conf call ID, Error: " + (CmError)ret); + } + + else + { + confData.CallId = callId; + } + + ret = Interop.CallManager.GetConfCallNumber(handle, out string number); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get conf call number, Error: " + (CmError)ret); + } + + else + { + confData.Number = number; + } + + ret = Interop.CallManager.GetConfCallPersonId(handle, out int personId); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get conf call person ID, Error: " + (CmError)ret); + } + + else + { + confData.PersonIndex = personId; + } + + ret = Interop.CallManager.GetConfCallNameMode(handle, out CallNameMode nameMode); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get conf call name mode, Error: " + (CmError)ret); + } + + else + { + confData.NameMode = nameMode; + } + + return confData; + } + + internal static CallEventData GetCallEventData(IntPtr handle) + { + CallEventData eventData = new CallEventData(); + int ret = Interop.CallManager.GetEventDataCallId(handle, out uint id); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get event data call ID, Error: " + (CmError)ret); + } + + else + { + eventData.EventId = id; + } + + ret = Interop.CallManager.GetSimSlot(handle, out MultiSimSlot simSlot); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get event data sim slot, Error: " + (CmError)ret); + } + + else + { + eventData.Slot = simSlot; + } + + ret = Interop.CallManager.GetEndCause(handle, out CallEndCause endCause); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get end cause, Error: " + (CmError)ret); + } + + else + { + eventData.Cause = endCause; + } + + ret = Interop.CallManager.GetIncomingCallData(handle, out IntPtr incoming); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get incoming call data, Error: " + (CmError)ret); + } + + else + { + eventData.Incoming = GetCallData(incoming); + } + + ret = Interop.CallManager.GetActiveCall(handle, out IntPtr active); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get active call data, Error: " + (CmError)ret); + } + + else + { + eventData.Active = GetCallData(active); + } + + ret = Interop.CallManager.GetHeldCall(handle, out IntPtr held); + if (ret != (int)CmError.None) + { + Log.Error(CmUtility.LogTag, "Failed to get held call data, Error: " + (CmError)ret); + } + + else + { + eventData.Held = GetCallData(held); + } + + return eventData; + } + + internal static void ThrowCmException(int exception) + { + _throwException(exception, false, ""); + } + + internal static void ThrowCmException(int exception, IntPtr handle) + { + _throwException(exception, (handle == IntPtr.Zero), ""); + } + + internal static void ThrowCmException(int exception, IntPtr handle, string message) + { + _throwException(exception, (handle == IntPtr.Zero), message); + } + + private static void _throwException(int exception, bool isHandleNull, string message) + { + CmError _error = (CmError)exception; + switch(_error) + { + case CmError.NotSupported: + throw new NotSupportedException("Unsupported feature: http://tizen.org/feature/network.telephony"); + case CmError.PermissionDenied: + throw new UnauthorizedAccessException("Permission denied: " + message); + case CmError.OutOfMemory: + throw new OutOfMemoryException("System out of memory"); + case CmError.InvalidParameter: + if (isHandleNull) + { + throw new InvalidOperationException("Invalid instance (object may have been disposed or released)"); + } + + throw new ArgumentException("Invalid parameter"); + default: + throw new InvalidOperationException(_error.ToString()); + } + } + } +} diff --git a/src/Tizen.CallManager/Tizen.CallManager/ConferenceCallData.cs b/src/Tizen.CallManager/Tizen.CallManager/ConferenceCallData.cs new file mode 100755 index 0000000..dcf83ae --- /dev/null +++ b/src/Tizen.CallManager/Tizen.CallManager/ConferenceCallData.cs @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.CallManager +{ + /// + /// A class which defines the properties of conference call. + /// + public class ConferenceCallData + { + internal uint CallId; + internal string Number; + internal int PersonIndex; + internal CallNameMode NameMode; + internal ConferenceCallData() + { + } + + /// + /// Conference call ID. + /// + public uint Id + { + get + { + return CallId; + } + } + + /// + /// Call number. + /// + public string CallNumber + { + get + { + return Number; + } + } + + /// + /// Person ID. + /// + public int PersonId + { + get + { + return PersonIndex; + } + } + + /// + /// Call name mode. + /// + public CallNameMode Mode + { + get + { + return NameMode; + } + } + } +} -- 2.7.4