Exemple #1
0
        /// <summary>
        /// Gets SIM 3G phonebook supported EFs like ANR, SNE, GRP, EMAIL and the corresponding EFs max text length, number length, and size.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <returns>A task containing an instance of PhonebookMetaInfo3G.</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 <PhonebookMetaInfo3G> GetPhonebookMetaInfo3G()
        {
            TaskCompletionSource <PhonebookMetaInfo3G> task = new TaskCompletionSource <PhonebookMetaInfo3G>();
            IntPtr id = (IntPtr)_requestId++;

            _callbackMap[id] = (handle, result, data, key) =>
            {
                Task taskResult = new Task(() =>
                {
                    if (result != (int)PhonebookAccessResult.Success)
                    {
                        Log.Error(TapiUtility.LogTag, "Error occurs during getting 3G phone book meta info: " + (PhonebookAccessResult)result);
                        task.SetException(new InvalidOperationException("Error occurs during getting 3G phone book meta info, " + (PhonebookAccessResult)result));
                        return;
                    }

                    PhonebookMetaInfo3GStruct metaInfo = Marshal.PtrToStructure <PhonebookMetaInfo3GStruct>(data);
                    task.SetResult(PhonebookStructConversions.ConvertPhonebookMetaInfo3GStruct(metaInfo));
                });
                taskResult.Start();
                taskResult.Wait();
                _callbackMap.Remove(key);
            };

            int ret = Interop.Tapi.Phonebook.GetPhonebookMetaInfo3G(_handle, _callbackMap[id], id);

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

            return(task.Task);
        }
        internal static PhonebookMetaInfo3G ConvertPhonebookMetaInfo3GStruct(PhonebookMetaInfo3GStruct infoStruct)
        {
            PhonebookMetaInfo3G info = new PhonebookMetaInfo3G();

            info.FileCount = infoStruct.FileTypeCount;
            List <FileTypeCapabilityInfo3G> capabilityList = new List <FileTypeCapabilityInfo3G>();

            foreach (FileTypeCapabilityInfo3GStruct capabilityInfo in infoStruct.FileTypeInfo)
            {
                capabilityList.Add(ConvertFileTypeCapabilityInfo3GStruct(capabilityInfo));
            }

            info.FileInfo = capabilityList;
            return(info);
        }