/// <summary> /// Provides an option to get the call forwarding status of different calls from the Network. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="ssClass">The Forward call type.</param> /// <param name="condition">The forward condition.</param> /// <returns>A task containing SS forward response information.</returns> /// <feature>http://tizen.org/feature/network.telephony</feature> /// <privilege>http://tizen.org/privilege/telephony</privilege> /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception> /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception> /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception> /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception> public Task <SsForwardResponse> SsGetForwardStatus(SsClass ssClass, SsForwardCondition condition) { TaskCompletionSource <SsForwardResponse> task = new TaskCompletionSource <SsForwardResponse>(); IntPtr id = (IntPtr)_requestId++; _callbackMap[id] = (handle, result, data, key) => { Task taskResult = new Task(() => { if (result != (int)SsCause.Success) { Log.Error(TapiUtility.LogTag, "Error occurs in getting SS forward status: " + (SsCause)result); task.SetException(new InvalidOperationException("Error occurs in getting SS forward status, " + (SsCause)result)); return; } SsForwardResponseStruct response = Marshal.PtrToStructure <SsForwardResponseStruct>(data); task.SetResult(SsStructConversions.ConvertForwardRspStruct(response)); }); taskResult.Start(); taskResult.Wait(); _callbackMap.Remove(key); }; int ret = Interop.Tapi.Ss.SsGetForwardStatus(_handle, ssClass, condition, _callbackMap[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to get forward status, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); } return(task.Task); }
internal static SsForwardResponse ConvertForwardRspStruct(SsForwardResponseStruct responseStruct) { SsForwardResponse info = new SsForwardResponse(); List <SsForwardRecord> recordList = new List <SsForwardRecord>(); foreach (SsForwardRecordStruct item in responseStruct.Record) { recordList.Add(ConvertSsForwardRecordStruct(item)); } info.RecordNum = responseStruct.RecordNum; info.RecordList = recordList; return(info); }
/// <summary> /// Allows to set the (register/erase/activate/deactivate) call forwarding option at the network. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="info">The Call forward information such as a forward mode, a forward type, and so on.</param> /// <returns>A task containing information about SS forward response.</returns> /// <feature>http://tizen.org/feature/network.telephony</feature> /// <privlevel>platform</privlevel> /// <privilege>http://tizen.org/privilege/telephony.admin</privilege> /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception> /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</exception> /// <exception cref="ArgumentNullException">Thrown when forward info is passed as null.</exception> /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception> /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception> public Task <SsForwardResponse> SsSetForwardInfo(SsForwardInfo info) { TaskCompletionSource <SsForwardResponse> task = new TaskCompletionSource <SsForwardResponse>(); IntPtr id = (IntPtr)_requestId++; _callbackMap[id] = (handle, result, data, key) => { Task taskResult = new Task(() => { if (result != (int)SsCause.Success) { Log.Error(TapiUtility.LogTag, "Error occurs in setting SS forward info: " + (SsCause)result); task.SetException(new InvalidOperationException("Error occurs in setting SS forward info, " + (SsCause)result)); return; } SsForwardResponseStruct response = Marshal.PtrToStructure <SsForwardResponseStruct>(data); task.SetResult(SsStructConversions.ConvertForwardRspStruct(response)); }); taskResult.Start(); taskResult.Wait(); _callbackMap.Remove(key); }; if (info == null) { throw new ArgumentNullException("Ss forward info is null"); } SsForwardInfoStruct infoStruct = SsClassConversions.ConvertSsForwardInfo(info); int ret = Interop.Tapi.Ss.SsSetForward(_handle, ref infoStruct, _callbackMap[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to set forward info, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); } return(task.Task); }
/// <summary> /// Registers a notification callback for notification change events on DBus interface. /// </summary> /// <param name="id">Notification id for which a callback has to be registered.</param> /// <feature>http://tizen.org/feature/network.telephony</feature> /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception> /// <exception cref="ArgumentException">Thrown when it is failed due to invalid parameter.</exception> /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation.</exception> public void RegisterNotiEvent(Notification id) { _notificationChangedCb = (IntPtr handle, IntPtr notiIdPtr, IntPtr data, IntPtr userData) => { if (_notificationChanged != null) { string notiId = null; object notiData = null; Notification noti = default(Notification); if (notiIdPtr != IntPtr.Zero) { notiId = Marshal.PtrToStringAnsi(notiIdPtr); foreach (Notification n in Enum.GetValues(typeof(Notification))) { if (notiId == TapiUtility.ConvertNotiToString(n)) { noti = n; break; } } } switch (noti) { case Notification.IdleVoiceCall: CallIdleStatusNotiStruct voiceIdleStatusNoti = Marshal.PtrToStructure <CallIdleStatusNotiStruct>(data); notiData = CallStructConversions.ConvertCallIdleStatusNoti(voiceIdleStatusNoti); break; case Notification.ActiveVoiceCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.HeldVoiceCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.DialingVoiceCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.AlertVoiceCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.IncomingVoiceCall: CallIncomingInfoStruct callIncomingInfo = Marshal.PtrToStructure <CallIncomingInfoStruct>(data); notiData = CallStructConversions.ConvertIncomingCallInfo(callIncomingInfo); break; case Notification.IdleVideoCall: CallIdleStatusNotiStruct videoIdleStatus = Marshal.PtrToStructure <CallIdleStatusNotiStruct>(data); notiData = CallStructConversions.ConvertCallIdleStatusNoti(videoIdleStatus); break; case Notification.ActiveVideoCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.DialingVideoCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.AlertVideoCall: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.IncomingVideoCall: CallIncomingInfoStruct videoIncomingInfo = Marshal.PtrToStructure <CallIncomingInfoStruct>(data); notiData = CallStructConversions.ConvertIncomingCallInfo(videoIncomingInfo); break; case Notification.WaitingCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.ForwardCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.BarredIncomingCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.BarredOutgoingCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.ForwardUnconditionalCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.ForwardConditionalCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.ForwardedCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.HeldCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.ActiveCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.JoinedCallInfo: notiData = (uint)Marshal.ReadInt32(data); break; case Notification.RecCallInfo: CallRecordStruct recordStruct = Marshal.PtrToStructure <CallRecordStruct>(data); notiData = CallStructConversions.ConvertCallRecordStruct(recordStruct); break; case Notification.PrivacyModeCall: notiData = (CallPrivacyMode)Marshal.ReadInt32(data); break; case Notification.OtaspCall: notiData = (CallOtaspStatus)Marshal.ReadInt32(data); break; case Notification.OtapaCall: notiData = (CallOtapaStatus)Marshal.ReadInt32(data); break; case Notification.CallSignalInfo: CallSignalInfoStruct signalInfoStruct = Marshal.PtrToStructure <CallSignalInfoStruct>(data); notiData = CallStructConversions.ConvertCallSignalInfo(signalInfoStruct); break; case Notification.CallSoundPath: notiData = (SoundPath)Marshal.ReadInt32(data); break; case Notification.CallSoundRingbackTone: notiData = (CallSoundRingbackNoti)Marshal.ReadInt32(data); break; case Notification.CallSoundWbamr: notiData = (CallSoundWbamrNoti)Marshal.ReadInt32(data); break; case Notification.CallSoundNoiceReduction: notiData = (CallSoundNoiseReduction)Marshal.ReadInt32(data); break; case Notification.CallSoundClock: int status = Marshal.ReadInt32(data); if (status == 1) { notiData = true; } else if (status == 0) { notiData = false; } break; case Notification.CallPreferredVoiceSubscription: notiData = (CallPreferredVoiceSubscription)Marshal.ReadInt32(data); break; case Notification.CallupgradeRequested: CallUpgradeDowngradeNotiStruct upgradeNotiStruct = Marshal.PtrToStructure <CallUpgradeDowngradeNotiStruct>(data); notiData = CallStructConversions.ConvertCallUpgradeNoti(upgradeNotiStruct); break; case Notification.CallDowngraded: CallUpgradeDowngradeNotiStruct downgradeNotiStruct = Marshal.PtrToStructure <CallUpgradeDowngradeNotiStruct>(data); notiData = CallStructConversions.ConvertCallUpgradeNoti(downgradeNotiStruct); break; case Notification.ModemPower: notiData = (PhonePowerStatus)Marshal.ReadInt32(data); break; case Notification.SimStatus: notiData = (SimCardStatus)Marshal.ReadInt32(data); break; case Notification.SimRefreshed: notiData = (SatCmdQualiRefresh)Marshal.ReadInt32(data); break; case Notification.SatSetupMenu: SatMainMenuInfoStruct mainMenuStruct = Marshal.PtrToStructure <SatMainMenuInfoStruct>(data); notiData = SatStructConversions.ConvertSatMainMenuInfoStruct(mainMenuStruct); break; case Notification.SatDisplayText: SatDisplayTextStruct textStruct = Marshal.PtrToStructure <SatDisplayTextStruct>(data); notiData = SatStructConversions.ConvertSatDisplayTextStruct(textStruct); break; case Notification.SatSelectItem: SatSelectItemStruct itemStruct = Marshal.PtrToStructure <SatSelectItemStruct>(data); notiData = SatStructConversions.ConvertSatSelectItemStruct(itemStruct); break; case Notification.SatGetInKey: SatGetInKeyStruct inKeyStruct = Marshal.PtrToStructure <SatGetInKeyStruct>(data); notiData = SatStructConversions.ConvertSatGetInKeyStruct(inKeyStruct); break; case Notification.SatGetInput: SatGetInputStruct inputStruct = Marshal.PtrToStructure <SatGetInputStruct>(data); notiData = SatStructConversions.ConvertSatGetInputStruct(inputStruct); break; case Notification.SatRefresh: SatRefreshStruct refreshStruct = Marshal.PtrToStructure <SatRefreshStruct>(data); notiData = SatStructConversions.ConvertSatRefreshStruct(refreshStruct); break; case Notification.SatSendSms: SatSendSmsStruct smsStruct = Marshal.PtrToStructure <SatSendSmsStruct>(data); notiData = SatStructConversions.ConvertSatSendSmsStruct(smsStruct); break; case Notification.SatSetupEventList: SatEventListDataStruct eventStruct = Marshal.PtrToStructure <SatEventListDataStruct>(data); notiData = SatStructConversions.ConvertSatEventListStruct(eventStruct); break; case Notification.SatSendDtmf: SatSendDtmfDataStruct dtmfStruct = Marshal.PtrToStructure <SatSendDtmfDataStruct>(data); notiData = SatStructConversions.ConvertSatSendDtmfStruct(dtmfStruct); break; case Notification.SatEndProactiveSession: notiData = (SatCommandType)Marshal.ReadInt32(data); break; case Notification.SatCallControlResult: SatCallCtrlIndDataStruct dataStruct = Marshal.PtrToStructure <SatCallCtrlIndDataStruct>(data); notiData = SatStructConversions.ConvertSatCallCtrlIndDataStruct(dataStruct); break; case Notification.SatMoSmControlResult: SatMoSmsCtrlDataStruct moStruct = Marshal.PtrToStructure <SatMoSmsCtrlDataStruct>(data); notiData = SatStructConversions.ConvertSatMoSmsCtrlDataStruct(moStruct); break; case Notification.SatSetupCall: SatSetupCallDataStruct callDataStruct = Marshal.PtrToStructure <SatSetupCallDataStruct>(data); notiData = SatStructConversions.ConvertSatSetupCallDataStruct(callDataStruct); break; case Notification.SatSendSs: SatSendSsDataStruct ssStruct = Marshal.PtrToStructure <SatSendSsDataStruct>(data); notiData = SatStructConversions.ConvertSatSendSsDataStruct(ssStruct); break; case Notification.SatSetupUssd: SatSetupUssdDataStruct ussdStruct = Marshal.PtrToStructure <SatSetupUssdDataStruct>(data); notiData = SatStructConversions.ConvertSatSetupUssdDataStruct(ussdStruct); break; case Notification.PhonebookStatus: SimPhonebookStatusStruct statusStruct = Marshal.PtrToStructure <SimPhonebookStatusStruct>(data); notiData = PhonebookStructConversions.ConvertSimPhonebookStatusStruct(statusStruct); break; case Notification.PhonebookContactChange: PhonebookContactChangeInfoStruct contactStruct = Marshal.PtrToStructure <PhonebookContactChangeInfoStruct>(data); notiData = PhonebookStructConversions.ConvertPhonebookContactChangeStruct(contactStruct); break; case Notification.NetworkRegistrationStatus: NetworkRegistrationStatusStruct nwStruct = Marshal.PtrToStructure <NetworkRegistrationStatusStruct>(data); notiData = NetworkStructConversions.ConvertNetworkRegistrationStruct(nwStruct); break; case Notification.NetworkCellInfo: NetworkCellNotiStruct notiStruct = Marshal.PtrToStructure <NetworkCellNotiStruct>(data); notiData = NetworkStructConversions.ConvertNetworkCellNotiStruct(notiStruct); break; case Notification.NetworkChange: NetworkChangeNotiStruct changeStruct = Marshal.PtrToStructure <NetworkChangeNotiStruct>(data); notiData = NetworkStructConversions.ConvertNetworkChangeStruct(changeStruct); break; case Notification.NetworkTimeInfo: NetworkTimeNotiStruct timeStruct = Marshal.PtrToStructure <NetworkTimeNotiStruct>(data); notiData = NetworkStructConversions.ConvertNetworkTimeNotiStruct(timeStruct); break; case Notification.NetworkIdentity: NetworkIdentityNotiStruct idStruct = Marshal.PtrToStructure <NetworkIdentityNotiStruct>(data); notiData = NetworkStructConversions.ConvertNetworkIdentityStruct(idStruct); break; case Notification.NetworkSignalStrength: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkEmergencyCallbackMode: notiData = (NetworkEmergencyCallbackMode)Marshal.ReadInt32(data); break; case Notification.NetworkDefaultDataSubscription: notiData = (NetworkDefaultDataSubscription)Marshal.ReadInt32(data); break; case Notification.NetworkDefaultSubscription: notiData = (NetworkDefaultSubscription)Marshal.ReadInt32(data); break; case Notification.NetworkCellId: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkLac: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkTac: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkSystemId: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkNetworkId: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkBsId: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkBsLatitude: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkBsLongitude: notiData = Marshal.ReadInt32(data); break; case Notification.NetworkVolteStatus: NetworkVolteStatusStruct volteStruct = Marshal.PtrToStructure <NetworkVolteStatusStruct>(data); notiData = NetworkStructConversions.ConvertNetworkVolteStruct(volteStruct); break; case Notification.NetworkEpdgStatus: int epdgStatus = Marshal.ReadInt32(data); if (epdgStatus == 1) { notiData = true; } else if (epdgStatus == 0) { notiData = false; } break; case Notification.SsUssd: SsUssdMsgInfoStruct ussdInfoStruct = Marshal.PtrToStructure <SsUssdMsgInfoStruct>(data); notiData = SsStructConversions.ConvertSsMsgStruct(ussdInfoStruct); break; case Notification.SsReleaseComplete: SsReleaseCompleteMsgStruct msgStruct = Marshal.PtrToStructure <SsReleaseCompleteMsgStruct>(data); notiData = SsStructConversions.ConvertReleaseMsgStruct(msgStruct); break; case Notification.SsNotifyForwarding: SsForwardResponseStruct responseStruct = Marshal.PtrToStructure <SsForwardResponseStruct>(data); notiData = SsStructConversions.ConvertForwardRspStruct(responseStruct); break; case Notification.SsNotifyBarring: SsBarringResponseStruct barringStruct = Marshal.PtrToStructure <SsBarringResponseStruct>(data); notiData = SsStructConversions.ConvertBarringRspStruct(barringStruct); break; case Notification.SsNotifyWaiting: SsWaitingResponseStruct waitingStruct = Marshal.PtrToStructure <SsWaitingResponseStruct>(data); notiData = SsStructConversions.ConvertWaitingRspStruct(waitingStruct); break; case Notification.SsNotifyInfo: SsInfoStruct ssInfoStruct = Marshal.PtrToStructure <SsInfoStruct>(data); notiData = SsStructConversions.ConvertInfoStruct(ssInfoStruct); break; case Notification.SmsIncomingMsg: SmsIncomingMsgNotiStruct smsNotiStruct = Marshal.PtrToStructure <SmsIncomingMsgNotiStruct>(data); notiData = SmsStructConversions.ConvertSmsIncomingStruct(smsNotiStruct); break; case Notification.SmsIncomingCbMsg: SmsIncomingCbMsgNotiStruct smsCbStruct = Marshal.PtrToStructure <SmsIncomingCbMsgNotiStruct>(data); notiData = SmsStructConversions.ConvertSmsIncomingCbStruct(smsCbStruct); break; case Notification.SmsIncomingEtwsMsg: SmsIncomingEtwsMsgNotiStruct etwsStruct = Marshal.PtrToStructure <SmsIncomingEtwsMsgNotiStruct>(data); notiData = SmsStructConversions.ConvertSmsIncomingEtwsStruct(etwsStruct); break; case Notification.SmsMemoryStatus: notiData = (SmsMemoryStatus)Marshal.ReadInt32(data); break; case Notification.SmsReady: notiData = (SmsReadyStatus)Marshal.ReadInt32(data); break; case Notification.OemData: OemDataStruct oemStruct = Marshal.PtrToStructure <OemDataStruct>(data); notiData = OemStructConversions.ConvertOemStruct(oemStruct); break; } _notificationChanged(null, new NotificationChangedEventArgs(noti, notiData)); } }; _notificationChangedCbList.Add(_notificationChangedCb); int ret = Interop.Tapi.RegisterNotiEvent(_handle, TapiUtility.ConvertNotiToString(id), _notificationChangedCb, IntPtr.Zero); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to register notification event, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle); } }