[Tapi] Implementation of Phonebook APIs
authoradhavan.m <adhavan.m@samsung.com>
Wed, 14 Jun 2017 06:02:27 +0000 (11:32 +0530)
committeradhavan.m <adhavan.m@samsung.com>
Fri, 16 Jun 2017 06:09:01 +0000 (11:39 +0530)
Change-Id: I6c09f4514cd749a9a5707637c7ccf0650077acd2
Signed-off-by: adhavan.m <adhavan.m@samsung.com>
src/Tizen.Tapi/Tizen.Tapi/Phonebook.cs [new file with mode: 0755]
src/Tizen.Tapi/Tizen.Tapi/PhonebookData.cs
src/Tizen.Tapi/Tizen.Tapi/PhonebookEnumerations.cs
src/Tizen.Tapi/Tizen.Tapi/PhonebookStructs.cs

diff --git a/src/Tizen.Tapi/Tizen.Tapi/Phonebook.cs b/src/Tizen.Tapi/Tizen.Tapi/Phonebook.cs
new file mode 100755 (executable)
index 0000000..419368a
--- /dev/null
@@ -0,0 +1,361 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+
+namespace Tizen.Tapi
+{
+    /// <summary>
+    /// A class which manages sim phonebook record information.
+    /// </summary>
+    public class Phonebook
+    {
+        private IntPtr _handle = IntPtr.Zero;
+        private Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback> _callbackMap = new Dictionary<IntPtr, Interop.Tapi.TapiResponseCallback>();
+        private int _requestId = 0;
+
+        private Phonebook()
+        {
+        }
+
+        /// <summary>
+        /// Gets the instance of Phonebook class.
+        /// </summary>
+        /// <param name="handle">An instance of TapiHandle obtained from InitTapi in TapiManager API.</param>
+        /// <exception cref="ArgumentNullException">Thrown when handle is passed as null.</exception>
+        public Phonebook(TapiHandle handle)
+        {
+            if (handle == null)
+            {
+                throw new ArgumentNullException("Handle is null");
+            }
+
+            _handle = handle._handle;
+        }
+
+        /// <summary>
+        /// Gets the current inserted SIM phonebook init status, available phonebook list, and first valid index in case of FDN, ADN, and 3G phonebook.
+        /// </summary>
+        /// <returns>An instance of SimPhonebookStatus containing init status and phonebook list 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 SimPhonebookStatus GetPhonebookInitInfo()
+        {
+            int isInitCompleted;
+            IntPtr pbList;
+            SimPhonebookStatusStruct pbStatus;
+            int ret = Interop.Tapi.Phonebook.GetPhonebookInitInfo(_handle, out isInitCompleted, out pbList);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to get phonebook init info, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony");
+            }
+
+            SimPhonebookListStruct pbListStruct = Marshal.PtrToStructure<SimPhonebookListStruct>(pbList);
+            pbStatus.IsInitCompleted = isInitCompleted;
+            pbStatus.PbList = pbListStruct;
+            return PhonebookStructConversions.ConvertSimPhonebookStatusStruct(pbStatus);
+        }
+
+        /// <summary>
+        /// Gets the number of used records and total records of a specific SIM phonebook type.
+        /// </summary>
+        /// <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));
+                    }
+
+                    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;
+        }
+
+        /// <summary>
+        /// Gets the max text length and max number length supported by the SIM phone book elementary file.
+        /// </summary>
+        /// <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));
+                    }
+
+                    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;
+        }
+
+        /// <summary>
+        /// Gets SIM 3G phonebook supported EFs like ANR, SNE, GRP, EMAIL and the corresponding EFs max text length, number length, and size.
+        /// </summary>
+        /// <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));
+                    }
+
+                    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;
+        }
+
+        /// <summary>
+        /// Reads SIM phone book entry information from the given storage type and index.
+        /// </summary>
+        /// <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));
+                    }
+
+                    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>
+        /// Adds or edits SIM phone book record entry information.
+        /// </summary>
+        /// <param name="record">The phonebook data to be updated or added.</param>
+        /// <returns>A task indicating whether the updation 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="ArgumentNullException">Thrown when record is passed as null.</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 UpdatePhonebookRecord(PhonebookRecord record)
+        {
+            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 updation of phone book record: " + (PhonebookAccessResult)result);
+                        task.SetException(new InvalidOperationException("Error occurs during updation of phone book record, " + (PhonebookAccessResult)result));
+                    }
+
+                    task.SetResult(true);
+                });
+                taskResult.Start();
+                taskResult.Wait();
+                _callbackMap.Remove(key);
+            };
+
+            if (record == null)
+            {
+                throw new ArgumentNullException("Phonebook record is null");
+            }
+
+            if (record.Index == 0)
+            {
+                throw new ArgumentException("Index in phonebook record is zero");
+            }
+
+            PhonebookRecordStruct recordStruct = PhonebookClassConversions.ConvertPhonebookrecord(record);
+            int ret = Interop.Tapi.Phonebook.UpdatePhonebookRecord(_handle, ref recordStruct, _callbackMap[id], id);
+            if (ret != (int)TapiError.Success)
+            {
+                Log.Error(TapiUtility.LogTag, "Failed to update phonebook record, Error: " + (TapiError)ret);
+                TapiUtility.ThrowTapiException(ret, _handle, "http://tizen.org/privilege/telephony.admin");
+            }
+
+            return task.Task;
+        }
+
+        /// <summary>
+        /// Deletes a SIM phonebook record.
+        /// </summary>
+        /// <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 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));
+                    }
+
+                    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;
+        }
+    }
+}
index a9e0b85..f28cd93 100755 (executable)
@@ -14,6 +14,8 @@
  * limitations under the License.
  */
 
+using System.Collections.Generic;
+
 namespace Tizen.Tapi
 {
     /// <summary>
@@ -191,4 +193,624 @@ namespace Tizen.Tapi
             }
         }
     }
+
+    /// <summary>
+    /// A class which defines phone book storage count information.
+    /// </summary>
+    public class PhonebookStorageInfo
+    {
+        internal PhonebookType PbType;
+        internal ushort PbTotalRecord;
+        internal ushort PbUsedRecord;
+        internal PhonebookStorageInfo()
+        {
+        }
+
+        /// <summary>
+        /// Storage file type.
+        /// </summary>
+        /// <value>Type of phone book storage file.</value>
+        public PhonebookType Type
+        {
+            get
+            {
+                return PbType;
+            }
+        }
+
+        /// <summary>
+        /// Total record count.
+        /// </summary>
+        /// <value>Count of total phonebook record.</value>
+        public ushort TotalRecord
+        {
+            get
+            {
+                return PbTotalRecord;
+            }
+        }
+
+        /// <summary>
+        /// Used record count.
+        /// </summary>
+        /// <value>Number of used phonebook record.</value>
+        public ushort UsedRecord
+        {
+            get
+            {
+                return PbUsedRecord;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which defines phone book entry information.
+    /// </summary>
+    public class PhonebookMetaInfo
+    {
+        internal PhonebookType MetaType;
+        internal ushort MinIdx;
+        internal ushort MaxIdx;
+        internal ushort NumMaxLength;
+        internal ushort TextMaxLen;
+        internal ushort UsedRecCount;
+        internal PhonebookMetaInfo()
+        {
+        }
+
+        /// <summary>
+        /// Storage file type.
+        /// </summary>
+        /// <value>Type of phonebook storage.</value>
+        public PhonebookType Type
+        {
+            get
+            {
+                return MetaType;
+            }
+        }
+
+        /// <summary>
+        /// Phone book minimum index.
+        /// </summary>
+        /// <value>Minimum index value of the phone book record.</value>
+        public ushort MinIndex
+        {
+            get
+            {
+                return MinIdx;
+            }
+        }
+
+        /// <summary>
+        /// Phone book maximum index.
+        /// </summary>
+        /// <value>Maximum index value of the phone book record.</value>
+        public ushort MaxIndex
+        {
+            get
+            {
+                return MaxIdx;
+            }
+        }
+
+        /// <summary>
+        /// Phone number's maximum length
+        /// </summary>
+        /// <value>Maximum length of the phone number.</value>
+        public ushort NumberMaxLength
+        {
+            get
+            {
+                return NumMaxLength;
+            }
+        }
+
+        /// <summary>
+        /// Text's maximum length.
+        /// </summary>
+        /// <value>Maximum length of the text.</value>
+        public ushort TextMaxLength
+        {
+            get
+            {
+                return TextMaxLen;
+            }
+        }
+
+        /// <summary>
+        /// Phone book used record count.
+        /// </summary>
+        /// <value>Number of used phone book record.</value>
+        public ushort UsedCount
+        {
+            get
+            {
+                return UsedRecCount;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which defines 3G phone book capability information.
+    /// </summary>
+    public class FileTypeCapabilityInfo3G
+    {
+        internal PhonebookFileType3G Type;
+        internal ushort MaxIdx;
+        internal ushort TextMaxLen;
+        internal ushort UsedRecCount;
+        internal FileTypeCapabilityInfo3G()
+        {
+        }
+
+        /// <summary>
+        /// 3G phonebook file type.
+        /// </summary>
+        /// <value>File type of the 3G phonebook.</value>
+        public PhonebookFileType3G FileType
+        {
+            get
+            {
+                return Type;
+            }
+        }
+
+        /// <summary>
+        /// Max index.
+        /// </summary>
+        /// <value>Maximum index value present in 3G phonebook.</value>
+        public ushort MaxIndex
+        {
+            get
+            {
+                return MaxIdx;
+            }
+        }
+
+        /// <summary>
+        /// Max text length.
+        /// </summary>
+        /// <value>Maximum text length in unsigned short.</value>
+        public ushort TextMaxLength
+        {
+            get
+            {
+                return TextMaxLen;
+            }
+        }
+
+        /// <summary>
+        /// Used record count.
+        /// </summary>
+        /// <value>Number of used record in 3G phonebook.</value>
+        public ushort UsedCount
+        {
+            get
+            {
+                return UsedRecCount;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which manages Sim phonebook and its capabilities information.
+    /// </summary>
+    public class PhonebookMetaInfo3G
+    {
+        internal ushort FileCount;
+        internal IEnumerable<FileTypeCapabilityInfo3G> FileInfo;
+        internal PhonebookMetaInfo3G()
+        {
+        }
+
+        /// <summary>
+        /// Phonebook file type count.
+        /// </summary>
+        /// <value>Filetype count of the 3G phonebook.</value>
+        public ushort FileTypeCount
+        {
+            get
+            {
+                return FileCount;
+            }
+        }
+
+        /// <summary>
+        /// Phonebook file type information.
+        /// </summary>
+        /// <value>A list of FileTypeCapabilityInfo3G instances.</value>
+        public IEnumerable<FileTypeCapabilityInfo3G> FileTypeInfo
+        {
+            get
+            {
+                return FileInfo;
+            }
+        }
+    }
+
+    /// <summary>
+    /// A class which contains information about phonebook record.
+    /// </summary>
+    public class PhonebookRecord
+    {
+        private PhonebookType _type;
+        private ushort _index;
+        private ushort _nextIndex;
+        private string _name;
+        private TextEncryptionType _dcs;
+        private string _number;
+        private SimTypeOfNumber _ton;
+        private string _sne;
+        private TextEncryptionType _sneDcs;
+        private string _anr1;
+        private SimTypeOfNumber _anr1Ton;
+        private string _anr2;
+        private SimTypeOfNumber _anr2Ton;
+        private string _anr3;
+        private SimTypeOfNumber _anr3Ton;
+        private string _email1;
+        private string _email2;
+        private string _email3;
+        private string _email4;
+        private ushort _groupIndex;
+        private ushort _pbControl;
+
+        /// <summary>
+        /// Phonebook type.
+        /// </summary>
+        /// <value>Type of the phonebook used.</value>
+        public PhonebookType Type
+        {
+            get
+            {
+                return _type;
+            }
+
+            set
+            {
+                _type = value;
+            }
+        }
+
+        /// <summary>
+        /// Index.
+        /// </summary>
+        /// <value>Index value represented in unsigned short.</value>
+        public ushort Index
+        {
+            get
+            {
+                return _index;
+            }
+
+            set
+            {
+                _index = value;
+            }
+        }
+
+        /// <summary>
+        /// Next index (This field is not used in the add/update case).
+        /// </summary>
+        /// <value>Next index represented in unsigned short.</value>
+        public ushort NextIndex
+        {
+            get
+            {
+                return _nextIndex;
+            }
+
+            set
+            {
+                _nextIndex = value;
+            }
+        }
+
+        /// <summary>
+        /// Name.
+        /// </summary>
+        /// <value>Name in phonebook record.</value>
+        public string Name
+        {
+            get
+            {
+                return _name;
+            }
+
+            set
+            {
+                _name = value;
+            }
+        }
+
+        /// <summary>
+        /// Dcs.
+        /// </summary>
+        /// <value>Sim encryption type.</value>
+        public TextEncryptionType Dcs
+        {
+            get
+            {
+                return _dcs;
+            }
+
+            set
+            {
+                _dcs = value;
+            }
+        }
+
+        /// <summary>
+        /// Number.
+        /// </summary>
+        /// <value>Number in phonebook record.</value>
+        public string Number
+        {
+            get
+            {
+                return _number;
+            }
+
+            set
+            {
+                _number = value;
+            }
+        }
+
+        /// <summary>
+        /// Ton.
+        /// </summary>
+        /// <value>Sim type of number.</value>
+        public SimTypeOfNumber Ton
+        {
+            get
+            {
+                return _ton;
+            }
+
+            set
+            {
+                _ton = value;
+            }
+        }
+
+        /// <summary>
+        /// SNE(Second Name Entry).
+        /// </summary>
+        /// <value>Second name entry in byte array.</value>
+        public string Sne
+        {
+            get
+            {
+                return _sne;
+            }
+
+            set
+            {
+                _sne = value;
+            }
+        }
+
+        /// <summary>
+        /// SNE DCS.
+        /// </summary>
+        /// <value>SNE text encryption type.</value>
+        public TextEncryptionType SneDcs
+        {
+            get
+            {
+                return _sneDcs;
+            }
+
+            set
+            {
+                _sneDcs = value;
+            }
+        }
+
+        /// <summary>
+        /// Additional Number1.
+        /// </summary>
+        /// <value>Additional number1 represented in byte array.</value>
+        public string Anr1
+        {
+            get
+            {
+                return _anr1;
+            }
+
+            set
+            {
+                _anr1 = value;
+            }
+        }
+
+        /// <summary>
+        /// ANR1 TON.
+        /// </summary>
+        /// <value>Additional number1 type of number.</value>
+        public SimTypeOfNumber Anr1Ton
+        {
+            get
+            {
+                return _anr1Ton;
+            }
+
+            set
+            {
+                _anr1Ton = value;
+            }
+        }
+
+        /// <summary>
+        /// Additional Number2.
+        /// </summary>
+        /// <value>Additional number2 represented in byte array.</value>
+        public string Anr2
+        {
+            get
+            {
+                return _anr2;
+            }
+
+            set
+            {
+                _anr2 = value;
+            }
+        }
+
+        /// <summary>
+        /// ANR2 TON.
+        /// </summary>
+        /// <value>Additional number2 type of number.</value>
+        public SimTypeOfNumber Anr2Ton
+        {
+            get
+            {
+                return _anr2Ton;
+            }
+
+            set
+            {
+                _anr2Ton = value;
+            }
+        }
+
+        /// <summary>
+        /// Additional number3.
+        /// </summary>
+        /// <value>Additional number3 represented in byte array.</value>
+        public string Anr3
+        {
+            get
+            {
+                return _anr3;
+            }
+
+            set
+            {
+                _anr3 = value;
+            }
+        }
+
+        /// <summary>
+        /// ANR3 TON.
+        /// </summary>
+        /// <value>Additional number3 type of number.</value>
+        public SimTypeOfNumber Anr3Ton
+        {
+            get
+            {
+                return _anr3Ton;
+            }
+
+            set
+            {
+                _anr3Ton = value;
+            }
+        }
+
+        /// <summary>
+        /// Email1.
+        /// </summary>
+        /// <value>Email1 represented in byte array.</value>
+        public string Email1
+        {
+            get
+            {
+                return _email1;
+            }
+
+            set
+            {
+                _email1 = value;
+            }
+        }
+
+        /// <summary>
+        /// Email2.
+        /// </summary>
+        /// <value>Email2 represented in byte array.</value>
+        public string Email2
+        {
+            get
+            {
+                return _email2;
+            }
+
+            set
+            {
+                _email2 = value;
+            }
+        }
+
+        /// <summary>
+        /// Email3.
+        /// </summary>
+        /// <value>Email3 represented in byte array.</value>
+        public string Email3
+        {
+            get
+            {
+                return _email3;
+            }
+
+            set
+            {
+                _email3 = value;
+            }
+        }
+
+        /// <summary>
+        /// Email4.
+        /// </summary>
+        /// <value>Email4 reprensented in byte array.</value>
+        public string Email4
+        {
+            get
+            {
+                return _email4;
+            }
+
+            set
+            {
+                _email4 = value;
+            }
+        }
+
+        /// <summary>
+        /// Group index.
+        /// </summary>
+        /// <value>Group index represented in unsigned short.</value>
+        public ushort GroupIndex
+        {
+            get
+            {
+                return _groupIndex;
+            }
+
+            set
+            {
+                _groupIndex = value;
+            }
+        }
+
+        /// <summary>
+        /// Phonebook control.
+        /// </summary>
+        /// <value>Phonebook control represented in unsigned short.</value>
+        public ushort PbControl
+        {
+            get
+            {
+                return _pbControl;
+            }
+
+            set
+            {
+                _pbControl = value;
+            }
+        }
+    }
 }
index 7142b63..414ecbc 100755 (executable)
@@ -69,4 +69,113 @@ namespace Tizen.Tapi
         /// </summary>
         Max
     }
+
+    /// <summary>
+    /// Enumeration for the storage field types in the 3G Phone book.
+    /// </summary>
+    public enum PhonebookFileType3G
+    {
+        /// <summary>
+        /// Name.
+        /// </summary>
+        Name = 0x01,
+        /// <summary>
+        /// Number.
+        /// </summary>
+        Number,
+        /// <summary>
+        /// First Another number.
+        /// </summary>
+        Anr1,
+        /// <summary>
+        /// Second Another number.
+        /// </summary>
+        Anr2,
+        /// <summary>
+        /// Third Another number.
+        /// </summary>
+        Anr3,
+        /// <summary>
+        /// First Email.
+        /// </summary>
+        Email1,
+        /// <summary>
+        /// Second Email.
+        /// </summary>
+        Email2,
+        /// <summary>
+        /// Third Email.
+        /// </summary>
+        Email3,
+        /// <summary>
+        /// Fourth Email.
+        /// </summary>
+        Email4,
+        /// <summary>
+        /// Second name entry of the main name.
+        /// </summary>
+        Sne,
+        /// <summary>
+        /// Group.
+        /// </summary>
+        Group,
+        /// <summary>
+        /// 1 byte control info and 1 byte hidden info.
+        /// </summary>
+        Pbc
+    }
+
+    /// <summary>
+    /// Enumeration for the text encryption type.
+    /// </summary>
+    public enum TextEncryptionType
+    {
+        /// <summary>
+        /// ASCII Encoding.
+        /// </summary>
+        Ascii,
+        /// <summary>
+        /// GSM 7 Bit Encoding.
+        /// </summary>
+        Gsm7Bit,
+        /// <summary>
+        /// UCS2 Encoding.
+        /// </summary>
+        Ucs2,
+        /// <summary>
+        /// HEX Encoding.
+        /// </summary>
+        Hex
+    }
+
+    /// <summary>
+    /// Enumeration for the phonebook access result.
+    /// </summary>
+    public enum PhonebookAccessResult
+    {
+        /// <summary>
+        /// SIM phonebook operation successful.
+        /// </summary>
+        Success,
+        /// <summary>
+        /// SIM phonebook operation failure.
+        /// </summary>
+        Fail,
+        /// <summary>
+        /// The index passed is not a valid index.
+        /// </summary>
+        InvalidIndex,
+        /// <summary>
+        /// The number length exceeds the max length allowed (or 0).
+        /// </summary>
+        InvalidNumberLength,
+        /// <summary>
+        /// The name length exceeds the max length allowed (or 0).
+        /// </summary>
+        InvalidNameLength,
+        /// <summary>
+        /// Access condition for PB file is not satisfied.
+        /// </summary>
+        AccessConditionNotSatisfied
+    }
 }
index 3580c32..74d8cf5 100755 (executable)
  */
 
 using System.Runtime.InteropServices;
+using System.Text;
+using System.Collections.Generic;
 
 namespace Tizen.Tapi
 {
     [StructLayout(LayoutKind.Sequential)]
     internal struct PhonebookRecordStruct
     {
+        internal PhonebookType Type;
+        internal ushort Index;
+        internal ushort NextIndex;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Name;
+        internal TextEncryptionType Dcs;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Number;
+        internal SimTypeOfNumber Ton;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Sne;
+        internal TextEncryptionType SneDcs;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Anr1;
+        internal SimTypeOfNumber Anr1Ton;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Anr2;
+        internal SimTypeOfNumber Anr2Ton;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Anr3;
+        internal SimTypeOfNumber Anr3Ton;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Email1;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Email2;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Email3;
+        [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
+        internal string Email4;
+        internal ushort GroupIndex;
+        internal ushort PbControl;
     }
 
     [StructLayout(LayoutKind.Sequential)]
@@ -49,6 +82,42 @@ namespace Tizen.Tapi
         internal PhonebookOperationType Operation;
     }
 
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct PhonebookStorageInfoStruct
+    {
+        internal PhonebookType Type;
+        internal ushort TotalRecord;
+        internal ushort UsedRecord;
+    }
+
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct PhonebookMetaInfoStruct
+    {
+        internal PhonebookType Type;
+        internal ushort MinIndex;
+        internal ushort MaxIndex;
+        internal ushort NumMaxLength;
+        internal ushort TextMaxLength;
+        internal ushort UsedCount;
+    }
+
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct FileTypeCapabilityInfo3GStruct
+    {
+        internal PhonebookFileType3G FileType;
+        internal ushort MaxIndex;
+        internal ushort MaxTextLen;
+        internal ushort UsedCount;
+    }
+
+    [StructLayout(LayoutKind.Sequential)]
+    internal struct PhonebookMetaInfo3GStruct
+    {
+        internal ushort FileTypeCount;
+        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 13, ArraySubType = UnmanagedType.LPStruct)]
+        internal FileTypeCapabilityInfo3GStruct[] FileTypeInfo;
+    }
+
     internal static class PhonebookStructConversions
     {
         internal static SimPhonebookList ConvertSimPhonebookListStruct(SimPhonebookListStruct listStruct)
@@ -80,6 +149,51 @@ namespace Tizen.Tapi
             return status;
         }
 
+        internal static PhonebookStorageInfo ConvertPhonebookStorageStruct(PhonebookStorageInfoStruct storageStruct)
+        {
+            PhonebookStorageInfo storageInfo = new PhonebookStorageInfo();
+            storageInfo.PbType = storageStruct.Type;
+            storageInfo.PbTotalRecord = storageStruct.TotalRecord;
+            storageInfo.PbUsedRecord = storageStruct.UsedRecord;
+            return storageInfo;
+        }
+
+        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;
+        }
+
+        internal static FileTypeCapabilityInfo3G ConvertFileTypeCapabilityInfo3GStruct(FileTypeCapabilityInfo3GStruct infoStruct)
+        {
+            FileTypeCapabilityInfo3G info = new FileTypeCapabilityInfo3G();
+            info.Type = infoStruct.FileType;
+            info.MaxIdx = infoStruct.MaxIndex;
+            info.TextMaxLen = infoStruct.MaxTextLen;
+            info.UsedRecCount = infoStruct.UsedCount;
+            return info;
+        }
+
+        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;
+        }
+
         internal static PhonebookContactChangeInfo ConvertPhonebookContactChangeStruct(PhonebookContactChangeInfoStruct infoStruct)
         {
             PhonebookContactChangeInfo info = new PhonebookContactChangeInfo();
@@ -88,5 +202,62 @@ namespace Tizen.Tapi
             info.OpType = infoStruct.Operation;
             return info;
         }
+
+        internal static PhonebookRecord ConvertPhonebookRecordStruct(PhonebookRecordStruct recordStruct)
+        {
+            PhonebookRecord record = new PhonebookRecord();
+            record.Type = recordStruct.Type;
+            record.Index = recordStruct.Index;
+            record.NextIndex = recordStruct.NextIndex;
+            record.Name = recordStruct.Name;
+            record.Dcs = recordStruct.Dcs;
+            record.Number = recordStruct.Number;
+            record.Ton = recordStruct.Ton;
+            record.Sne = recordStruct.Sne;
+            record.SneDcs = recordStruct.SneDcs;
+            record.Anr1 = recordStruct.Anr1;
+            record.Anr1Ton = recordStruct.Anr1Ton;
+            record.Anr2 = recordStruct.Anr2;
+            record.Anr2Ton = recordStruct.Anr2Ton;
+            record.Anr3 = recordStruct.Anr3;
+            record.Anr3Ton = recordStruct.Anr3Ton;
+            record.Email1 = recordStruct.Email1;
+            record.Email2 = recordStruct.Email2;
+            record.Email3 = recordStruct.Email3;
+            record.Email4 = recordStruct.Email4;
+            record.GroupIndex = recordStruct.GroupIndex;
+            record.PbControl = recordStruct.PbControl;
+            return record;
+        }
+    }
+
+    internal static class PhonebookClassConversions
+    {
+        internal static PhonebookRecordStruct ConvertPhonebookrecord(PhonebookRecord record)
+        {
+            PhonebookRecordStruct recordStruct = new PhonebookRecordStruct();
+            recordStruct.Type = record.Type;
+            recordStruct.Index = record.Index;
+            recordStruct.NextIndex = record.NextIndex;
+            recordStruct.Name = record.Name;
+            recordStruct.Dcs = record.Dcs;
+            recordStruct.Number = record.Number;
+            recordStruct.Ton = record.Ton;
+            recordStruct.Sne = record.Sne;
+            recordStruct.SneDcs = record.SneDcs;
+            recordStruct.Anr1 = record.Anr1;
+            recordStruct.Anr1Ton = record.Anr1Ton;
+            recordStruct.Anr2 = record.Anr2;
+            recordStruct.Anr2Ton = record.Anr2Ton;
+            recordStruct.Anr3 = record.Anr3;
+            recordStruct.Anr3Ton = record.Anr3Ton;
+            recordStruct.Email1 = record.Email1;
+            recordStruct.Email2 = record.Email2;
+            recordStruct.Email3 = record.Email3;
+            recordStruct.Email4 = record.Email4;
+            recordStruct.GroupIndex = record.GroupIndex;
+            recordStruct.PbControl = record.PbControl;
+            return recordStruct;
+        }
     }
 }