/// <summary> /// Gets the max text length and max number length supported by the SIM phone book elementary file. /// </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 PhonebookMetaInfo.</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 <PhonebookMetaInfo> GetPhonebookMetaInfo(PhonebookType type) { TaskCompletionSource <PhonebookMetaInfo> task = new TaskCompletionSource <PhonebookMetaInfo>(); 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 meta info: " + (PhonebookAccessResult)result); task.SetException(new InvalidOperationException("Error occurs during getting phone book meta info, " + (PhonebookAccessResult)result)); return; } PhonebookMetaInfoStruct info = Marshal.PtrToStructure <PhonebookMetaInfoStruct>(data); task.SetResult(PhonebookStructConversions.ConvertPhonebookMetaInfoStruct(info)); }); taskResult.Start(); taskResult.Wait(); _callbackMap.Remove(key); }; int ret = Interop.Tapi.Phonebook.GetPhonebookMetaInfo(_handle, type, _callbackMap[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to get phonebook meta info, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); } return(task.Task); }
internal static PhonebookMetaInfo ConvertPhonebookMetaInfoStruct(PhonebookMetaInfoStruct metaStruct) { PhonebookMetaInfo info = new PhonebookMetaInfo(); info.MetaType = metaStruct.Type; info.MinIdx = metaStruct.MinIndex; info.MaxIdx = metaStruct.MaxIndex; info.NumMaxLength = metaStruct.NumMaxLength; info.TextMaxLen = metaStruct.TextMaxLength; info.UsedRecCount = metaStruct.UsedCount; return(info); }