Fixed the issue that IsDefault() returns false for default categories
authorhs321.lee <hs321.lee@samsung.com>
Sat, 4 May 2013 06:28:00 +0000 (15:28 +0900)
committerhs321.lee <hs321.lee@samsung.com>
Sat, 4 May 2013 06:28:00 +0000 (15:28 +0900)
Change-Id: I7f39cc287755ef14e69f0e60bf17fb5a9e882784
Signed-off-by: hs321.lee <hs321.lee@samsung.com>
src/FScl_AddressbookImpl.cpp
src/FScl_AddressbookManagerImpl.cpp
src/FScl_CategoryImpl.cpp

index 3c1a561..e41c7ed 100644 (file)
@@ -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));
 
-       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));
+       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));
 
        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));
index 68dcf31..33801c9 100644 (file)
@@ -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));
 
-       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));
+       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));
 
        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));
index 4dbc80f..f08bfc9 100644 (file)
@@ -169,11 +169,15 @@ _CategoryImpl::operator =(const _CategoryImpl& rhs)
 bool
 _CategoryImpl::IsDefault(void) const
 {
-       bool isDefault = false;
+       char* pCharValue = null;
 
-       contacts_record_get_bool(__recordHandle, _contacts_group.is_read_only, &isDefault);
+       contacts_record_get_str_p(__recordHandle, _contacts_group.extra_data, &pCharValue);
+       if (pCharValue != null)
+       {
+               return true;
+       }
 
-       return isDefault;
+       return false;
 }
 
 void
@@ -328,17 +332,14 @@ _CategoryImpl::RemoveMember(RecordId contactId)
 result
 _CategoryImpl::SetName(const String& name)
 {
-       bool isDefault = false;
-       contacts_record_get_bool(__recordHandle, _contacts_group.is_read_only, &isDefault);
-
        if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
        {
-               SysTryReturn(NID_SCL, !isDefault, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. This category is a default category.", GetErrorMessage(E_INVALID_ARG));
+               SysTryReturn(NID_SCL, !IsDefault(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. This category is a default category.", GetErrorMessage(E_INVALID_ARG));
                SysTryReturn(NID_SCL, name.GetLength() <= 100, E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified name exceeds the max length.", GetErrorMessage(E_INVALID_ARG));
        }
        else
        {
-               SysTryReturn(NID_SCL, !isDefault, E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] This category is a default category.", GetErrorMessage(E_INVALID_OPERATION));
+               SysTryReturn(NID_SCL, !IsDefault(), E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] This category is a default category.", GetErrorMessage(E_INVALID_OPERATION));
        }
 
        SysTryReturn(NID_SCL, !name.IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified file path is an empty string", GetErrorMessage(E_INVALID_ARG));