From 5e7010e8cfae2f10a1f339823718c9d260cd7e8a Mon Sep 17 00:00:00 2001 From: Gwangbok Kim Date: Thu, 30 May 2013 16:23:53 +0900 Subject: [PATCH] fix N_SE-37895 Change-Id: Ied0dde7d09a3bf79d058173e772bf997530f8c06 Signed-off-by: Gwangbok Kim --- src/FSclCategory.cpp | 6 +++--- src/FScl_AddressbookImpl.cpp | 6 +++--- src/FScl_AddressbookManagerImpl.cpp | 6 +++--- src/FScl_CategoryImpl.cpp | 33 ++++++++++++++++++++++++++++++--- src/inc/FScl_CategoryImpl.h | 2 ++ 5 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/FSclCategory.cpp b/src/FSclCategory.cpp index 8867bdf..70a40df 100644 --- a/src/FSclCategory.cpp +++ b/src/FSclCategory.cpp @@ -78,12 +78,12 @@ Category::Equals(const Object& rhs) const return false; } - if (GetRecordId() == pCategory->GetRecordId()) + if (GetRecordId() != pCategory->GetRecordId()) { - return true; + return false; } - return false; + return __pCategoryImpl->Equals(*pCategory->__pCategoryImpl); } int diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp index e41c7ed..3c1a561 100644 --- a/src/FScl_AddressbookImpl.cpp +++ b/src/FScl_AddressbookImpl.cpp @@ -455,9 +455,9 @@ _AddressbookImpl::RemoveCategory(RecordId categoryId) 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)); - char* pCharValue = null; - contacts_record_get_str_p(recordHandle, _contacts_group.extra_data, &pCharValue); - SysTryReturn(NID_SCL, pCharValue == null, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG)); + bool isReadOnly = false; + contacts_record_get_bool(recordHandle, _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)); diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp index 96fcf5c..e531d7a 100644 --- a/src/FScl_AddressbookManagerImpl.cpp +++ b/src/FScl_AddressbookManagerImpl.cpp @@ -481,9 +481,9 @@ _AddressbookManagerImpl::RemoveCategory(RecordId categoryId) 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)); - char* pCharValue = null; - contacts_record_get_str_p(recordHandle, _contacts_group.extra_data, &pCharValue); - SysTryReturn(NID_SCL, pCharValue == null, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified category is a default category.", GetErrorMessage(E_INVALID_ARG)); + bool isReadOnly = false; + contacts_record_get_bool(recordHandle, _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_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); diff --git a/src/FScl_CategoryImpl.cpp b/src/FScl_CategoryImpl.cpp index f08bfc9..6c4f822 100644 --- a/src/FScl_CategoryImpl.cpp +++ b/src/FScl_CategoryImpl.cpp @@ -167,12 +167,39 @@ _CategoryImpl::operator =(const _CategoryImpl& rhs) } bool +_CategoryImpl::Equals(const Tizen::Base::Object& rhs) const +{ + const _CategoryImpl* pCategoryImpl = dynamic_cast(&rhs); + if (pCategoryImpl == null) + { + return false; + } + + if (GetName() != pCategoryImpl->GetName()) + { + return false; + } + + if (GetRingtonePath() != pCategoryImpl->GetRingtonePath()) + { + return false; + } + + if (GetThumbnailPath() != pCategoryImpl->GetThumbnailPath()) + { + return false; + } + + return true; +} + +bool _CategoryImpl::IsDefault(void) const { - char* pCharValue = null; + bool isReadOnly = false; - contacts_record_get_str_p(__recordHandle, _contacts_group.extra_data, &pCharValue); - if (pCharValue != null) + contacts_record_get_bool(__recordHandle, _contacts_group.is_read_only, &isReadOnly); + if (isReadOnly) { return true; } diff --git a/src/inc/FScl_CategoryImpl.h b/src/inc/FScl_CategoryImpl.h index 8cde556..82c1bd3 100644 --- a/src/inc/FScl_CategoryImpl.h +++ b/src/inc/FScl_CategoryImpl.h @@ -74,6 +74,8 @@ public: */ virtual ~_CategoryImpl(void); + virtual bool Equals(const Tizen::Base::Object& rhs) const; + void SetRecordHandle(contacts_record_h recordHandle); contacts_record_h GetRecordHandle(void) const; -- 2.7.4