fixed DCM-1707
authorGwangbok Kim <gwangbok.kim@samsung.com>
Mon, 20 May 2013 05:35:47 +0000 (14:35 +0900)
committerGwangbok Kim <gwangbok.kim@samsung.com>
Mon, 20 May 2013 08:06:05 +0000 (17:06 +0900)
Change-Id: Ibd2cbff7593f5be1dcceeb3f70f7aa4b92a71808
Signed-off-by: Gwangbok Kim <gwangbok.kim@samsung.com>
src/FScl_ContactImpl.cpp
src/inc/FScl_ContactImpl.h

index 1d2a1e8..5a20a13 100644 (file)
@@ -2203,6 +2203,7 @@ _ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
        String stringValue;
        int type = 0;
        int oriType = 0;
+       PhoneNumberType phoneNumberType = PHONENUMBER_TYPE_HOME;
 
        contacts_record_get_child_record_count(__contactHandle, _contacts_contact.number, &count);
        SysTryReturn(NID_SCL, count > (unsigned int) index, E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[%s] index=%d must be less than the current count(%d) of phone numbers.", GetErrorMessage(E_OUT_OF_RANGE), index, count);
@@ -2241,46 +2242,14 @@ _ContactImpl::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
                case PHONENUMBER_TYPE_OTHER:
                        contacts_record_get_int(recordHandle, _contacts_number.type, &oriType);
 
-                       if (oriType == (CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE)
-                               || oriType == (CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE)
-                               || oriType == CONTACTS_NUMBER_TYPE_CELL
-                               || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME)
-                               || oriType == (CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK)
-                               || oriType == CONTACTS_NUMBER_TYPE_PAGER)
+                       phoneNumberType = GetNativePhoneNumberType(oriType);
+                       if (phoneNumberType == PHONENUMBER_TYPE_OTHER)
                        {
-                               type = CONTACTS_NUMBER_TYPE_OTHER;
-                       }
-                       else if (oriType == CONTACTS_NUMBER_TYPE_CUSTOM)
-                       {
-                               if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
-                               {
-                                       char* pCharValue = null;
-
-                                       contacts_record_get_str_p(recordHandle, _contacts_number.label, &pCharValue);
-
-                                       stringValue = pCharValue;
-                                       type = CONTACTS_NUMBER_TYPE_CUSTOM;
-
-                               }
-                               else
-                               {
-                                       type = CONTACTS_NUMBER_TYPE_OTHER;
-                               }
-                       }
-                       else if (oriType == CONTACTS_NUMBER_TYPE_ASSISTANT)
-                       {
-                               if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
-                               {
-                                       type = CONTACTS_NUMBER_TYPE_ASSISTANT;
-                               }
-                               else
-                               {
-                                       type = CONTACTS_NUMBER_TYPE_OTHER;
-                               }
+                               type = oriType;
                        }
                        else
                        {
-                               type = oriType;
+                               type = CONTACTS_NUMBER_TYPE_OTHER;
                        }
                        break;
                default:
@@ -3451,6 +3420,88 @@ _ContactImpl::GetNicknamesN(void) const
        return pList.release();
 }
 
+PhoneNumberType
+_ContactImpl::GetNativePhoneNumberType(int coreType) const
+{
+       PhoneNumberType type = PHONENUMBER_TYPE_HOME;
+
+       switch (coreType)
+       {
+               case CONTACTS_NUMBER_TYPE_HOME:
+                       // fall through
+               case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_HOME;
+                       break;
+               case CONTACTS_NUMBER_TYPE_WORK:
+                       // fall through
+               case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
+                       type = PHONENUMBER_TYPE_WORK;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CELL:
+                       type = PHONENUMBER_TYPE_MOBILE;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX:
+                       // fall through
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
+                       type = PHONENUMBER_TYPE_HOME_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
+                       type = PHONENUMBER_TYPE_WORK_FAX;
+                       break;
+               case CONTACTS_NUMBER_TYPE_PAGER:
+                       type = PHONENUMBER_TYPE_PAGER;
+                       break;
+               case CONTACTS_NUMBER_TYPE_CUSTOM:
+                       type = PHONENUMBER_TYPE_CUSTOM;
+                       break;
+               case CONTACTS_NUMBER_TYPE_ASSISTANT:
+                       if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
+                       {
+                               type = PHONENUMBER_TYPE_OTHER;
+                       }
+                       else
+                       {
+                               type = PHONENUMBER_TYPE_ASSISTANT;
+                       }
+                       break;
+               case CONTACTS_NUMBER_TYPE_OTHER:
+                       type = PHONENUMBER_TYPE_OTHER;
+                       break;
+               default:
+                       if (coreType & CONTACTS_NUMBER_TYPE_FAX)
+                       {
+                               type = PHONENUMBER_TYPE_HOME_FAX;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_CELL)
+                       {
+                               type = PHONENUMBER_TYPE_MOBILE;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_PAGER)
+                       {
+                               type = PHONENUMBER_TYPE_PAGER;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_HOME)
+                       {
+                               type = PHONENUMBER_TYPE_HOME;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_WORK)
+                       {
+                               type = PHONENUMBER_TYPE_WORK;
+                       }
+                       else if (coreType & CONTACTS_NUMBER_TYPE_VOICE)
+                       {
+                               type = PHONENUMBER_TYPE_HOME;
+                       }
+                       else
+                       {
+                               type = PHONENUMBER_TYPE_OTHER;
+                       }
+                       break;
+       }
+
+       return type;
+}
+
 IList*
 _ContactImpl::GetPhoneNumbersN(void) const
 {
@@ -3488,79 +3539,7 @@ _ContactImpl::GetPhoneNumbersN(void) const
 
                contacts_record_get_int(numberHandle, _contacts_number.type, &intValue);
 
-               switch (intValue)
-               {
-                       case CONTACTS_NUMBER_TYPE_HOME:
-                               // fall through
-                       case CONTACTS_NUMBER_TYPE_HOME | CONTACTS_NUMBER_TYPE_VOICE:
-                               type = PHONENUMBER_TYPE_HOME;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_WORK:
-                               // fall through
-                       case CONTACTS_NUMBER_TYPE_WORK | CONTACTS_NUMBER_TYPE_VOICE:
-                               type = PHONENUMBER_TYPE_WORK;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_CELL:
-                               type = PHONENUMBER_TYPE_MOBILE;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_FAX:
-                               // fall through
-                       case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_HOME:
-                               type = PHONENUMBER_TYPE_HOME_FAX;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_FAX | CONTACTS_NUMBER_TYPE_WORK:
-                               type = PHONENUMBER_TYPE_WORK_FAX;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_PAGER:
-                               type = PHONENUMBER_TYPE_PAGER;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_CUSTOM:
-                               type = PHONENUMBER_TYPE_CUSTOM;
-                               break;
-                       case CONTACTS_NUMBER_TYPE_ASSISTANT:
-                               if (_AppInfo::GetApiVersion() < _API_VERSION_2_1)
-                               {
-                                       type = PHONENUMBER_TYPE_OTHER;
-                               }
-                               else
-                               {
-                                       type = PHONENUMBER_TYPE_ASSISTANT;
-                               }
-                               break;
-                       case CONTACTS_NUMBER_TYPE_OTHER:
-                               type = PHONENUMBER_TYPE_OTHER;
-                               break;
-                       default:
-                               if (intValue & CONTACTS_NUMBER_TYPE_FAX)
-                               {
-                                       type = PHONENUMBER_TYPE_HOME_FAX;
-                               }
-                               else if (intValue & CONTACTS_NUMBER_TYPE_CELL)
-                               {
-                                       type = PHONENUMBER_TYPE_MOBILE;
-                               }
-                               else if (intValue & CONTACTS_NUMBER_TYPE_PAGER)
-                               {
-                                       type = PHONENUMBER_TYPE_PAGER;
-                               }
-                               else if (intValue & CONTACTS_NUMBER_TYPE_HOME)
-                               {
-                                       type = PHONENUMBER_TYPE_HOME;
-                               }
-                               else if (intValue & CONTACTS_NUMBER_TYPE_WORK)
-                               {
-                                       type = PHONENUMBER_TYPE_WORK;
-                               }
-                               else if (intValue & CONTACTS_NUMBER_TYPE_VOICE)
-                               {
-                                       type = PHONENUMBER_TYPE_HOME;
-                               }
-                               else
-                               {
-                                       type = PHONENUMBER_TYPE_OTHER;
-                               }
-                               break;
-               }
+               type = GetNativePhoneNumberType(intValue);
 
                _PhoneNumberImpl::GetInstance(*pPhoneNumber)->SetType(type);
 
index 422b521..7566641 100644 (file)
@@ -168,6 +168,8 @@ public:
 
        void SetAsFavorite(bool isFavorite = true);
 
+       PhoneNumberType GetNativePhoneNumberType(int coreType) const;
+
        _OSP_EXPORT_ static const _ContactImpl* GetInstance(const Contact& contact);
 
        _OSP_EXPORT_ static _ContactImpl* GetInstance(Contact& contact);