Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        internal static IEnumerable <NetworkPreferredPlmnInfo> ConvertNetworkPreferredPlmnStruct(NetworkPreferredPlmnListStruct plmnStruct)
        {
            List <NetworkPreferredPlmnInfo> plmnList = new List <NetworkPreferredPlmnInfo>();

            for (int i = 0; i <= plmnStruct.Count; i++)
            {
                NetworkPreferredPlmnInfo plmnInfo = new NetworkPreferredPlmnInfo();
                plmnInfo.idex        = plmnStruct.PlmnList[i].Index;
                plmnInfo.NwName      = plmnStruct.PlmnList[i].NetworkName;
                plmnInfo.NwPlmn      = plmnStruct.PlmnList[i].Plmn;
                plmnInfo.SvcProvName = plmnStruct.PlmnList[i].SnName;
                plmnInfo.SysType     = plmnStruct.PlmnList[i].Type;
                plmnList.Add(plmnInfo);
            }

            return(plmnList);
        }
Exemplo n.º 3
0
        /// <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");
            }
        }