From: vivek Date: Fri, 5 Jul 2013 09:21:47 +0000 (+0530) Subject: Replaced all references to contacts_db_delete_record by DeleteContactRecord X-Git-Tag: submit/tizen_2.2/20131107.062123~34 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ffcd54e9ed197243707038ab8866a4373240ed10;hp=b7fd12f69738cd081111f73953c0c03afb11f95d;p=framework%2Fosp%2Fsocial.git Replaced all references to contacts_db_delete_record by DeleteContactRecord Change-Id: I2ea0b5784d01425d6d49b83824be22273ac1abe3 Signed-off-by: vivek --- diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp index 30f3716..9113253 100644 --- a/src/FScl_AddressbookImpl.cpp +++ b/src/FScl_AddressbookImpl.cpp @@ -20,6 +20,7 @@ * This file contains definitions of @e _AddressbookImpl class. */ #include +#include #include #include #include @@ -48,6 +49,7 @@ #include "FScl_UserProfileImpl.h" #include "FScl_ContactDbConnector.h" +using namespace std; using namespace Tizen::App; using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -329,7 +331,7 @@ _AddressbookImpl::AddCategory(Category& category) int recordId = 0; contacts_record_h recordHandle = null; - std::unique_ptr > pList(null); + unique_ptr > pList(null); recordHandle = _CategoryImpl::GetInstance(category)->GetRecordHandle(); @@ -375,7 +377,7 @@ _AddressbookImpl::AddCategory(Category& category) pList.reset(_CategoryImpl::GetInstance(category)->GetAddedMembersN()); if (pList != null && pList->GetCount() > 0) { - std::unique_ptr > pEnum(pList->GetEnumeratorN()); + unique_ptr > pEnum(pList->GetEnumeratorN()); while (pEnum->MoveNext() == E_SUCCESS) { @@ -394,28 +396,10 @@ _AddressbookImpl::AddCategory(Category& category) result _AddressbookImpl::RemoveContact(RecordId contactId) { - SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId); + SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is invalid", GetErrorMessage(E_INVALID_ARG)); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - int intValue = 0; - int ret = CONTACTS_ERROR_NONE; - contacts_record_h recordHandle = null; - - ret = contacts_db_get_record(_contacts_simple_contact._uri, contactId, &recordHandle); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); - - contacts_record_get_int(recordHandle, _contacts_simple_contact.id, &intValue); - - contacts_record_destroy(recordHandle, true); - - SysTryReturn(NID_SCL, intValue == contactId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - - ret = contacts_db_delete_record(_contacts_contact._uri, contactId); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + result r = _AddressbookUtil::DeleteContactRecord(_contacts_contact._uri, contactId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; } @@ -440,29 +424,15 @@ _AddressbookImpl::RemoveCategory(RecordId categoryId) { SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - int intValue = 0; - int ret = CONTACTS_ERROR_NONE; - contacts_record_h recordHandle = null; - - ret = contacts_db_get_record(_contacts_group._uri, categoryId, &recordHandle); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The category is not found."); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); - - __ContactsRecordHandle categoryHandle(recordHandle); - - contacts_record_get_int(recordHandle, _contacts_group.id, &intValue); - SysTryReturn(NID_SCL, intValue == categoryId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); + unique_ptr pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId)); + SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); bool isReadOnly = false; - contacts_record_get_bool(recordHandle, _contacts_group.is_read_only, &isReadOnly); + contacts_record_get_bool(pCategoryRecord.get(), _contacts_group.is_read_only, &isReadOnly); SysTryReturn(NID_SCL, !isReadOnly, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG)); - ret = contacts_db_delete_record(_contacts_group._uri, categoryId); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - 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_NONE, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] Failed remove a category."); + result r = _AddressbookUtil::DeleteContactRecord(_contacts_group._uri, categoryId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; } @@ -1337,9 +1307,8 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile) { if (pExistingProfile != null) { - ret = contacts_db_delete_record(_contacts_my_profile._uri, existingRecordId); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + r = _AddressbookUtil::DeleteContactRecord(_contacts_my_profile._uri, existingRecordId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); } contacts_record_h newRecordHandle = null; @@ -1376,9 +1345,8 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile) { if (pExistingProfile != null) { - ret = contacts_db_delete_record(_contacts_my_profile._uri, existingRecordId); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + r = _AddressbookUtil::DeleteContactRecord(_contacts_my_profile._uri, existingRecordId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); } contacts_record_h newRecordHandle = null; @@ -1413,9 +1381,8 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile) { if (pExistingProfile != null) { - ret = contacts_db_delete_record(_contacts_my_profile._uri, existingRecordId); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + r = _AddressbookUtil::DeleteContactRecord(_contacts_my_profile._uri, existingRecordId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); } } diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp index 0c811ac..4bcf99c 100644 --- a/src/FScl_AddressbookManagerImpl.cpp +++ b/src/FScl_AddressbookManagerImpl.cpp @@ -444,18 +444,8 @@ _AddressbookManagerImpl::RemoveContact(RecordId contactId) { SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contactId is invalid.", GetErrorMessage(E_INVALID_ARG)); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - unique_ptr pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId)); - SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - int intValue = 0; - contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.id, &intValue); - SysTryReturn(NID_SCL, intValue == contactId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - - int ret = contacts_db_delete_record(_contacts_contact._uri, contactId); - 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 contact is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + result r = _AddressbookUtil::DeleteContactRecord(_contacts_contact._uri, contactId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; } @@ -463,24 +453,18 @@ _AddressbookManagerImpl::RemoveContact(RecordId contactId) result _AddressbookManagerImpl::RemoveCategory(RecordId categoryId) { - SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. categoryId = %d.", GetErrorMessage(E_INVALID_ARG), categoryId); + SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified categoryId is invalid", GetErrorMessage(E_INVALID_ARG)); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); unique_ptr pCategoryRecord(_AddressbookUtil::GetContactRecordN(_contacts_group._uri, categoryId)); SysTryReturn(NID_SCL, pCategoryRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - int intValue = 0; - contacts_record_get_int(pCategoryRecord.get(), _contacts_group.id, &intValue); - SysTryReturn(NID_SCL, intValue == categoryId, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); - bool isReadOnly = false; contacts_record_get_bool(pCategoryRecord.get(), _contacts_group.is_read_only, &isReadOnly); SysTryReturn(NID_SCL, !isReadOnly, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG)); - int ret = contacts_db_delete_record(_contacts_group._uri, categoryId); - 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 category is not found.", GetErrorMessage(E_OBJ_NOT_FOUND)); -// SysTryReturnResult(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OPERATION_FAILED, "Failed to delete a category.(%d)", ret); // temp + result r = _AddressbookUtil::DeleteContactRecord(_contacts_group._uri, categoryId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; } @@ -1316,16 +1300,11 @@ _AddressbookManagerImpl::OnRelationChanged(void) result _AddressbookManagerImpl::RemovePerson(PersonId personId) { - SysTryReturnResult(NID_SCL, personId > 0, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId); + SysTryReturnResult(NID_SCL, personId > 0, E_INVALID_ARG, "[%s] Invalid argument is used. ", GetErrorMessage(E_INVALID_ARG)); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - unique_ptr pPersonRecord(_AddressbookUtil::GetContactRecordN(_contacts_person._uri, personId)); - SysTryReturn(NID_SCL, pPersonRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - int ret = contacts_db_delete_record(_contacts_person._uri, personId); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The person is not found."); - 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_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Failed remove a person.", GetErrorMessage(E_SYSTEM)); + result r = _AddressbookUtil::DeleteContactRecord(_contacts_person._uri, personId); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); return E_SUCCESS; }