Removed contacts_db_delete_record and added DeleteContactRecord in AddressbookUtil...
authorvivek <vivek.ellur@samsung.com>
Fri, 21 Jun 2013 11:46:38 +0000 (17:16 +0530)
committervivek <vivek.ellur@samsung.com>
Wed, 26 Jun 2013 05:36:29 +0000 (11:06 +0530)
Change-Id: Ic54bff01a2b5aa23135d02661be036566401c12c
Signed-off-by: vivek <vivek.ellur@samsung.com>
src/FScl_AddressbookManagerImpl.cpp
src/FScl_AddressbookUtil.h

index 9d61c18..3698b66 100644 (file)
@@ -249,13 +249,10 @@ _AddressbookManagerImpl::CreateAddressbookN(AccountId accountId, const String& n
 result
 _AddressbookManagerImpl::DeleteAddressbook(AddressbookId addressbookId)
 {
-       SysTryReturn(NID_SCL, addressbookId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The addressbook ID is invalid or the default addressbook ID.", GetErrorMessage(E_INVALID_ARG));
+       SysTryReturn(NID_SCL, addressbookId > 0, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument used.The addressbook ID is invalid or the default addressbook ID.", GetErrorMessage(E_INVALID_ARG));
        SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
-       int ret = contacts_db_delete_record(_contacts_address_book._uri, addressbookId);
-       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-       SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The addressbook is not found.", GetErrorMessage(E_OBJ_NOT_FOUND));
-//     SysTryReturnResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OPERATION_FAILED, "Failed to delete an addressbook.(%d)", ret); // temp
+       result r = _AddressbookUtil::DeleteContactRecord(_contacts_address_book._uri, addressbookId);
+       SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
 
        return E_SUCCESS;
 }
index a09076e..4a3d259 100644 (file)
@@ -822,20 +822,29 @@ public:
                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_FILE_NO_SPACE, E_STORAGE_FULL, E_STORAGE_FULL, "[%s] The storage is insufficient. (%d)", GetErrorMessage(E_STORAGE_FULL), ret);
                SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
 
-
                return E_SUCCESS;
        }
 
+       static result DeleteContactRecord(const char* pUri, int recordId)
+       {
+               int ret = contacts_db_delete_record(pUri, recordId);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The record is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
+
+               return E_SUCCESS;
+       }
 
        static ContactRecord* GetContactRecordN(const char* pUri, RecordId recordId)
        {
                ClearLastResult();
 
                contacts_record_h recordHandle = null;
+
                int ret = contacts_db_get_record(pUri, recordId, &recordHandle);
                SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed. (%d)", GetErrorMessage(E_OUT_OF_MEMORY), ret);
-               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, null, E_OBJ_NOT_FOUND, "[%s] The record %d is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), recordId, ret);
-               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred. Record Id(%d). (%d)", GetErrorMessage(E_SYSTEM), recordId, ret);
+               SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, null, E_OBJ_NOT_FOUND, "[%s] The record is not found. (%d)", GetErrorMessage(E_OBJ_NOT_FOUND), ret);
+               SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_SYSTEM, "[%s] A system error has been occurred. (%d)", GetErrorMessage(E_SYSTEM), ret);
 
                return recordHandle;
        }