/// <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); }
public static CommandArgs BuildCommandArgs(PhonebookType phonebookType, string searchString, bool recursive) { CommandArgs args = new CommandArgs("PhonebookType", phonebookType.ToString()); args.Add("Recursive", recursive.ToString()); args.Add("SearchString", searchString); return(args); }
internal PhonebookSearchResults(Phonebook phonebook, PhonebookType type, string searchString) { _phonebook = phonebook; _type = type; _searchString = searchString; _errorMessage = "No Results"; _searchWasSuccessful = true; _items = new List <PhonebookItem>(); }
internal PhonebookSearchResults(Phonebook phonebook, PhonebookType type, string searchString, string errorMessage, params object[] args) { _phonebook = phonebook; _type = type; _searchString = searchString; _errorMessage = string.Format(errorMessage, args); _searchWasSuccessful = false; _items = new List <PhonebookItem>(); }
public static CommandArgs BuildCommandArgs(PhonebookType phonebookType, string folderId) { CommandArgs args = new CommandArgs("PhonebookType", phonebookType.ToString()); if (phonebookType == PhonebookType.Local) { args.Add("Recursive", "False"); } args.Add("FolderId", folderId); return(args); }
internal PhonebookSearchResults(Phonebook phonebook, PhonebookType type, string searchString, string folderId, IEnumerable <PhonebookItem> items, int offset, int limit, int totalRows, string currentFolderId, string currentFolderName) { _phonebook = phonebook; _type = type; _searchString = searchString; _folderId = folderId; _offset = offset; _limit = limit; _totalRows = totalRows; _currentFolderId = currentFolderId; _currentFolderName = currentFolderName; _items = new List <PhonebookItem>(items); }
internal PhonebookContact(CiscoTelePresenceCodec codec, XElement element, PhonebookType phonebookType) : base(codec, element.Element("ContactId").Value, element.Element("FolderId") != null ? element.Element("FolderId").Value : string.Empty, element.Element("Name").Value, phonebookType) { foreach (var newMethod in from contactMethod in element.Elements("ContactMethod") let id = int.Parse(contactMethod.Element("ContactMethodId").Value) let number = contactMethod.Element("Number").Value select new PhonebookContactMethod(this) { Id = id, Number = number }) { _contactMethods.Add(newMethod.Id, newMethod); } }
/// <summary> /// Reads SIM phone book entry information from the given storage type and index. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="type">The different storage types to be selected in the SIM.</param> /// <param name="index">The index for accessing the SIM data.</param> /// <returns>A task containing an instance of PhonebookRecord.</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 <PhonebookRecord> ReadPhonebookRecord(PhonebookType type, ushort index) { TaskCompletionSource <PhonebookRecord> task = new TaskCompletionSource <PhonebookRecord>(); 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 reading phone book record: " + (PhonebookAccessResult)result); task.SetException(new InvalidOperationException("Error occurs during reading phone book record, " + (PhonebookAccessResult)result)); return; } PhonebookRecordStruct record = Marshal.PtrToStructure <PhonebookRecordStruct>(data); task.SetResult(PhonebookStructConversions.ConvertPhonebookRecordStruct(record)); }); taskResult.Start(); taskResult.Wait(); _callbackMap.Remove(key); }; if (index == 0) { throw new ArgumentException("Index should not be zero"); } int ret = Interop.Tapi.Phonebook.ReadPhonebookRecord(_handle, type, index, _callbackMap[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to read phonebook record, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony"); } return(task.Task); }
/// <summary> /// Deletes a SIM phonebook record. /// </summary> /// <since_tizen> 4 </since_tizen> /// <param name="type">The different storage types to be selected in the SIM.</param> /// <param name="index">The index of the record to be deleted.</param> /// <returns>A task indicating whether deletion is done or not.</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="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 <bool> DeletePhonebookRecord(PhonebookType type, ushort index) { TaskCompletionSource <bool> task = new TaskCompletionSource <bool>(); 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 deletion of phone book record: " + (PhonebookAccessResult)result); task.SetException(new InvalidOperationException("Error occurs during deletion of phone book record, " + (PhonebookAccessResult)result)); return; } task.SetResult(true); }); taskResult.Start(); taskResult.Wait(); _callbackMap.Remove(key); }; if (index == 0) { throw new ArgumentException("Index of the record is zero"); } int ret = Interop.Tapi.Phonebook.DeletePhonebookRecord(_handle, type, index, _callbackMap[id], id); if (ret != (int)TapiError.Success) { Log.Error(TapiUtility.LogTag, "Failed to delete phonebook record, Error: " + (TapiError)ret); TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin"); } return(task.Task); }
internal static extern int DeletePhonebookRecord(IntPtr handle, PhonebookType pbType, ushort pbIndex, TapiResponseCallback cb, IntPtr userData);
internal static extern int GetPhonebookMetaInfo(IntPtr handle, PhonebookType pbType, TapiResponseCallback cb, IntPtr userData);
protected PhonebookItem(CiscoTelePresenceCodec codec, string id, string parentId, string name, PhonebookType phonebookType) { _codec = codec; Id = id; ParentId = parentId; Name = name; if (this is PhonebookContact) { Type = PhonebookItemType.Contact; } }
public PhonebookSearchResults Search(PhonebookType type, string searchString, int limit, int offset, string folderId) { var cmd = new CodecCommand("Phonebook", "Search"); cmd.Args.Add(type); cmd.Args.Add("SearchString", searchString); cmd.Args.Add("Limit", limit); cmd.Args.Add("Offset", offset); cmd.Args.Add("Recursive", !string.IsNullOrEmpty(searchString)); if (!string.IsNullOrEmpty(folderId)) { cmd.Args.Add("FolderId", folderId); } #if DEBUG Debug.WriteInfo("Searching Phonebook"); var sw = new Stopwatch(); sw.Start(); foreach (var arg in cmd.Args) { Debug.WriteInfo(" " + arg.Name, arg.Value.ToString()); } #endif var response = _codec.SendCommand(cmd); #if DEBUG Debug.WriteInfo("Phonbook search response", "Code = {0}, Stopwatch = {1}", response.Code, sw.ElapsedMilliseconds); #endif if (response.Code != 200) { CloudLog.Error("Error getting phonebook search, Codec Responded with {0} code", response.Code); return(new PhonebookSearchResults(this, type, searchString, folderId, "Codec returned Error code: {0}", response.Code)); } var result = response.Xml.Element("Command").Element("PhonebookSearchResult"); if (result.Attribute("status").Value == "Error") { var message = result.Element("Reason").Value; CloudLog.Error("Error getting phonebook search: {0}", message); return(new PhonebookSearchResults(this, type, searchString, message)); } if (result.Attribute("status").Value == "OK" && result.IsEmpty) { return(new PhonebookSearchResults(this, type, searchString)); } try { var folders = result.Elements("Folder"); var contacts = result.Elements("Contact"); var info = result.Element("ResultInfo"); var totalRows = int.Parse(info.Element("TotalRows").Value); var items = folders.Select( xElement => new PhonebookFolder(_codec, xElement, type)).Cast <PhonebookItem>().ToList(); items.AddRange( contacts.Select( xElement => new PhonebookContact(_codec, xElement, type)).Cast <PhonebookItem>()); foreach (var folder in folders) { _folderNames[folder.Element("LocalId").Value] = folder.Element("Name").Value; } #if DEBUG Debug.WriteSuccess("Search Results", "{0} to {1} of {2}", offset + 1, offset + items.Count, totalRows); foreach (var phonebookItem in items) { Debug.WriteSuccess(phonebookItem.Type.ToString(), "{0} ({1}/{2})", phonebookItem.Name, phonebookItem.Id, phonebookItem.ParentId); } sw.Stop(); Debug.WriteInfo("Phonbook search returning", "Count = {0}, Stopwatch = {1}", items.Count, sw.ElapsedMilliseconds); #endif if (!String.IsNullOrEmpty((string)cmd.Args.First(a => a.Name == "SearchString").Value)) { return(new PhonebookSearchResults(this, type, searchString, folderId, items, offset, limit, totalRows, string.Empty, string.Empty)); } foreach (var element in result.Elements()) { string currentFolderId; switch (element.Name) { case "Contact": if (element.Element("FolderId") != null) { currentFolderId = element.Element("FolderId").Value; return(new PhonebookSearchResults(this, type, searchString, folderId, items, offset, limit, totalRows, currentFolderId, _folderNames[currentFolderId])); } return(new PhonebookSearchResults(this, type, searchString, folderId, items, offset, limit, totalRows, string.Empty, string.Empty)); case "Folder": if (element.Element("ParentFolderId") != null) { currentFolderId = element.Element("ParentFolderId").Value; return(new PhonebookSearchResults(this, type, searchString, folderId, items, offset, limit, totalRows, currentFolderId, _folderNames[currentFolderId])); } return(new PhonebookSearchResults(this, type, searchString, folderId, items, offset, limit, totalRows, string.Empty, string.Empty)); } } return(new PhonebookSearchResults(this, type, searchString, folderId, items, offset, limit, totalRows, string.Empty, string.Empty)); } catch (Exception e) { var message = string.Format("Error parsing phonebook data, {0}", e.Message); if (e is ThreadAbortException) { message = "Thread was aborted"; } else { CloudLog.Error(message); } return(new PhonebookSearchResults(this, type, searchString, message)); } }
public PhonebookSearchResults Search(PhonebookType type, string searchString, int limit, int offset) { return(Search(type, searchString, limit, offset, null)); }
public PhonebookFolder(CiscoTelePresenceCodec codec, XElement element, PhonebookType phonebookType) : base(codec, element.Element("LocalId").Value, element.Element("FolderId").Value, element.Element("Name").Value, phonebookType) { }