Exemple #1
0
        /// <summary>
        /// Gets the status of the calling line identity service.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <param name="type">The Cli service type.</param>
        /// <returns>A task containing SS CLI response information.</returns>
        /// <feature>http://tizen.org/feature/network.telephony</feature>
        /// <privilege>http://tizen.org/privilege/telephony</privilege>
        /// <exception cref="NotSupportedException">Thrown when telephony feature is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when privilege access is denied.</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 <SsCliResponse> SsGetCliStatus(SsCliType type)
        {
            TaskCompletionSource <SsCliResponse> task = new TaskCompletionSource <SsCliResponse>();
            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 getting SS CLI status: " + (SsCause)result);
                        task.SetException(new InvalidOperationException("Error occurs in getting SS CLI status, " + (SsCause)result));
                        return;
                    }

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

            int ret = Interop.Tapi.Ss.SsGetCliStatus(_handle, type, _callbackMap[id], id);

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

            return(task.Task);
        }
Exemple #2
0
        internal static SsCliResponse ConvertSsCliResponseStruct(SsCliResponseStruct responseStruct)
        {
            SsCliResponse response = new SsCliResponse();

            response.LineType  = responseStruct.Type;
            response.CliStatus = responseStruct.Status;
            return(response);
        }