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);
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:
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
{
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);