예제 #1
0
        internal static SsWaitingInfoStruct ConvertSsWaitingInfo(SsWaitingInfo info)
        {
            SsWaitingInfoStruct waitingStruct = new SsWaitingInfoStruct();

            waitingStruct.Class = info.Class;
            waitingStruct.Mode  = info.Mode;
            return(waitingStruct);
        }
예제 #2
0
        /// <summary>
        /// Activates/deactivates the call waiting service.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="info">The status of call-waiting service.</param>
        /// <returns>A task containing SS waiting response information.</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 waiting 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 <SsWaitingResponse> SsSetWaitingInfo(SsWaitingInfo info)
        {
            TaskCompletionSource <SsWaitingResponse> task = new TaskCompletionSource <SsWaitingResponse>();
            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 waiting info: " + (SsCause)result);
                        task.SetException(new InvalidOperationException("Error occurs in setting SS waiting info, " + (SsCause)result));
                        return;
                    }

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

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

            SsWaitingInfoStruct infoStruct = SsClassConversions.ConvertSsWaitingInfo(info);
            int ret = Interop.Tapi.Ss.SsSetWaiting(_handle, ref infoStruct, _callbackMap[id], id);

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

            return(task.Task);
        }