internal static SsForwardInfoStruct ConvertSsForwardInfo(SsForwardInfo info) { SsForwardInfoStruct forwardStruct = new SsForwardInfoStruct(); forwardStruct.Class = info.Class; forwardStruct.Mode = info.Mode; forwardStruct.Condition = info.Condition; forwardStruct.NoReplyTimer = info.NoReplyTimer; forwardStruct.Ton = info.Ton; forwardStruct.Npi = info.Npi; forwardStruct.PhoneNumber = info.PhoneNumber; return(forwardStruct); }
/// <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); }