示例#1
0
        internal static NetworkPlmnList ConvertNetworkPlmnListStruct(NetworkPlmnListStruct listStruct)
        {
            NetworkPlmnList        plmnList = new NetworkPlmnList();
            List <NetworkIdentity> records  = new List <NetworkIdentity>();

            foreach (NetworkIdentityStruct idStruct in listStruct.NwList)
            {
                NetworkIdentity identity = new NetworkIdentity();
                identity.Id = idStruct.PlmnId;
                identity.SvcProviderName = idStruct.SvcName;
                identity.IdName          = idStruct.NwName;
                identity.PlmnName        = idStruct.NwPlmn;
                identity.PlmnNwType      = idStruct.Type;
                identity.SysType         = idStruct.Act;
                records.Add(identity);
            }

            plmnList.NwCount = listStruct.NwCount;
            plmnList.NwList  = records;
            return(plmnList);
        }
示例#2
0
文件: Network.cs 项目: prjung/TizenFX
        /// <summary>
        /// Sends a request to do manual search for the available networks and provides the Network List to the user asynchronously.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>Instance of NetworkPlmnList.</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.InvalidOperationException">Thrown when network instance is invalid or when method failed due to invalid operation.</exception>
        public Task <NetworkPlmnList> SearchNetwork()
        {
            TaskCompletionSource <NetworkPlmnList> task = new TaskCompletionSource <NetworkPlmnList>();
            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 manual search for the available networks, " + (TapiError)result);
                        task.SetException(new InvalidOperationException("Error occurs during manual search for the available networks, " + (TapiError)result));
                        return;
                    }

                    NetworkPlmnListStruct listStruct = Marshal.PtrToStructure <NetworkPlmnListStruct>(dataResponse);
                    NetworkPlmnList plmnClass        = NetworkStructConversions.ConvertNetworkPlmnListStruct(listStruct);
                    task.SetResult(plmnClass);
                });

                resultTask.Start();
                resultTask.Wait();
                _response_map.Remove(key);
            };

            int ret = Interop.Tapi.Network.SearchNetwork(_handle, _response_map[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to do manual search for the available networks, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }