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);
        }
Beispiel #2
0
        /// <summary>
        /// Adds or edits SIM phone book record entry information.
        /// </summary>
        /// <since_tizen> 4 </since_tizen>
        /// <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 <bool> 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));
                        return;
                    }

                    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);
        }