internal static NetworkPreferredPlmnStruct ConvertNetworkPreferredPlmn(NetworkPreferredPlmnInfo plmnInfo) { NetworkPreferredPlmnStruct plmnStruct = new NetworkPreferredPlmnStruct(); plmnStruct.Index = plmnInfo.idex; plmnStruct.NetworkName = plmnInfo.NwName; plmnStruct.Plmn = plmnInfo.NwPlmn; plmnStruct.SnName = plmnInfo.SvcProvName; plmnStruct.Type = plmnInfo.SysType; return(plmnStruct); }
/// <summary> /// Set the network preferred plmn asynchronously. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="operation">The operation to be done on the preferred plmn.</param> /// <param name="info">The preferred plmn info.</param> /// <returns>A task indicating whether the SetNetworkPreferredPlmn method is done or not.</returns> /// <privilege>http://tizen.org/privilege/telephony.admin</privilege> /// <privlevel>platform</privlevel> /// <feature>http://tizen.org/feature/network.telephony</feature> /// <exception cref="System.NotSupportedException">Thrown when feature is not supported.</exception> /// <exception cref="System.UnauthorizedAccessException">Thrown when privilege access is denied.</exception> /// <exception cref="System.ArgumentNullException">Thrown when NetworkPreferredPlmnInfo argument is null.</exception> /// <exception cref="System.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception> public Task SetNetworkPreferredPlmn(NetworkPreferredPlmnOp operation, NetworkPreferredPlmnInfo info) { if (info != null) { TaskCompletionSource <bool> task = new TaskCompletionSource <bool>(); IntPtr id; id = (IntPtr)_requestId++; _response_map[id] = (IntPtr handle, int result, IntPtr dataResponse, IntPtr key) => { Task resultTask = new Task(() => { if (result != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Error occurs during setting the network preferred plmn, " + (TapiError)result); task.SetException(new InvalidOperationException("Error occurs during setting the network preferred plmn, " + (TapiError)result)); return; } task.SetResult(true); }); resultTask.Start(); resultTask.Wait(); _response_map.Remove(key); }; NetworkPreferredPlmnStruct plmnStruct = NetworkClassConversions.ConvertNetworkPreferredPlmn(info); int ret = Interop.Tapi.Network.SetNetworkPreferredPlmn(_handle, operation, ref plmnStruct, _response_map[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to set the network preferred plmn, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); } return(task.Task); } else { throw new ArgumentNullException("NetworkPreferredPlmnInfo argument is null"); } }