/// <summary> /// Gets the number of used records and total records of a specific SIM phonebook type. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="type">The different storage types to be selected in the SIM.</param> /// <returns>A task containing an instance of PhonebookStorageInfo.</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 <PhonebookStorageInfo> GetPhonebookStorage(PhonebookType type) { TaskCompletionSource <PhonebookStorageInfo> task = new TaskCompletionSource <PhonebookStorageInfo>(); 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 phone book storage: " + (PhonebookAccessResult)result); task.SetException(new InvalidOperationException("Error occurs during getting phone book storage, " + (PhonebookAccessResult)result)); return; } PhonebookStorageInfoStruct info = Marshal.PtrToStructure <PhonebookStorageInfoStruct>(data); task.SetResult(PhonebookStructConversions.ConvertPhonebookStorageStruct(info)); }); taskResult.Start(); taskResult.Wait(); _callbackMap.Remove(key); }; int ret = Interop.Tapi.Phonebook.GetPhonebookStorage(_handle, type, _callbackMap[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to get phonebook storage info, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); } return(task.Task); }
internal static PhonebookStorageInfo ConvertPhonebookStorageStruct(PhonebookStorageInfoStruct storageStruct) { PhonebookStorageInfo storageInfo = new PhonebookStorageInfo(); storageInfo.PbType = storageStruct.Type; storageInfo.PbTotalRecord = storageStruct.TotalRecord; storageInfo.PbUsedRecord = storageStruct.UsedRecord; return(storageInfo); }