From: vivek Date: Fri, 21 Jun 2013 11:46:38 +0000 (+0530) Subject: Removed contacts_db_delete_record and added DeleteContactRecord in AddressbookUtil... X-Git-Tag: submit/tizen_2.2/20130714.153047~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=789125a94243118910e1339854f165aa9b678bae;p=framework%2Fosp%2Fsocial.git Removed contacts_db_delete_record and added DeleteContactRecord in AddressbookUtil class Change-Id: Ic54bff01a2b5aa23135d02661be036566401c12c Signed-off-by: vivek --- diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp index 9d61c18..3698b66 100644 --- a/src/FScl_AddressbookManagerImpl.cpp +++ b/src/FScl_AddressbookManagerImpl.cpp @@ -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; } diff --git a/src/FScl_AddressbookUtil.h b/src/FScl_AddressbookUtil.h index a09076e..4a3d259 100644 --- a/src/FScl_AddressbookUtil.h +++ b/src/FScl_AddressbookUtil.h @@ -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; }