Пример #1
0
        internal static SsBarringInfoStruct ConvertSsBarringInfo(SsBarringInfo info)
        {
            SsBarringInfoStruct barringStruct = new SsBarringInfoStruct();

            barringStruct.Class    = info.Class;
            barringStruct.Mode     = info.Mode;
            barringStruct.Type     = info.Type;
            barringStruct.Password = info.Password;
            return(barringStruct);
        }
Пример #2
0
        /// <summary>
        /// Sends a request to activate/deactivate call barring.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="info">The information about call barring.</param>
        /// <returns>A task containing an instance of SsBarringResponse which contains information about barring 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 barring 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 <SsBarringResponse> SsSetBarring(SsBarringInfo info)
        {
            TaskCompletionSource <SsBarringResponse> task = new TaskCompletionSource <SsBarringResponse>();
            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 during setting SS barring info: " + (SsCause)result);
                        task.SetException(new InvalidOperationException("Error occurs during setting SS barring info, " + (SsCause)result));
                        return;
                    }

                    SsBarringResponseStruct response = Marshal.PtrToStructure <SsBarringResponseStruct>(data);
                    task.SetResult(SsStructConversions.ConvertBarringRspStruct(response));
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            if (info == null)
            {
                throw new ArgumentNullException("Ss barring info is null");
            }

            SsBarringInfoStruct infoStruct = SsClassConversions.ConvertSsBarringInfo(info);
            int ret = Interop.Tapi.Ss.SsSetBarring(_handle, ref infoStruct, _callbackMap[id], id);

            if (ret != (int)TapiError.Success)
            {
                Log.Error(TapiUtility.LogTag, "Failed to set barring info, Error: " + (TapiError)ret);
                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
            }

            return(task.Task);
        }