char* pVcardStream = null;
int ret = CONTACTS_ERROR_NONE;
- Contact tempContact;
- contacts_record_h contactHandle = null;
-
- result r = _AddressbookUtil::ConvertUserProfileToContact(userProfile, tempContact);
- SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ contacts_record_h recordHandle = null;
- contactHandle = _ContactImpl::GetInstance(tempContact)->GetContactRecordHandle();
+ recordHandle = _UserProfileImpl::GetInstance(userProfile)->GetUserProfileHandle();
- ret = contacts_vcard_make_from_contact(contactHandle, &pVcardStream);
+ ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
std::unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- r = pByteBuffer->Construct(strlen(pChar.get()));
+ result r = pByteBuffer->Construct(strlen(pChar.get()));
SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
while (pEnum->MoveNext() == E_SUCCESS)
{
- Contact tempContact;
- contacts_record_h contactHandle = null;
+ contacts_record_h recordHandle = null;
pProfile = static_cast<UserProfile*>(pEnum->GetCurrent());
- r = _AddressbookUtil::ConvertUserProfileToContact(*pProfile, tempContact);
- SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
-
- contactHandle = _ContactImpl::GetInstance(tempContact)->GetContactRecordHandle();
+ recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle();
- ret = contacts_vcard_make_from_contact(contactHandle, &pVcardStream);
+ ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_INVALID_PARAMETER, null, E_INVALID_ARG, "[%s] Invalid argument is used.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_SYSTEM, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
SysTryReturn(NID_SCL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
char* pVcardStream = null;
- Contact tempContact;
- contacts_record_h contactHandle = null;
-
- r = _AddressbookUtil::ConvertUserProfileToContact(userProfile, tempContact);
- SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ contacts_record_h recordHandle = null;
- contactHandle = _ContactImpl::GetInstance(tempContact)->GetContactRecordHandle();
+ recordHandle = _UserProfileImpl::GetInstance(userProfile)->GetUserProfileHandle();
- int ret = contacts_vcard_make_from_contact(contactHandle, &pVcardStream);
+ int ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
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));
while (pEnum->MoveNext() == E_SUCCESS)
{
- Contact tempContact;
- contacts_record_h contactHandle = null;
+ contacts_record_h recordHandle = null;
pProfile = static_cast<UserProfile*>(pEnum->GetCurrent());
- r = _AddressbookUtil::ConvertUserProfileToContact(*pProfile, tempContact);
- SysTryReturn(NID_SCL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
-
- contactHandle = _ContactImpl::GetInstance(tempContact)->GetContactRecordHandle();
+ recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle();
- ret = contacts_vcard_make_from_contact(contactHandle, &pVcardStream);
+ ret = contacts_vcard_make_from_my_profile(recordHandle, &pVcardStream);
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));
return pQueryResult;
}
-result
-_AddressbookUtil::ConvertUserProfileToContact(const UserProfile& userProfile, Contact& contact)
-{
- result r = E_SUCCESS;
-
- r = contact.SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, userProfile.GetValue(USER_PROFILE_PROPERTY_ID_FIRST_NAME));
- SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Failed to set USER_PROFILE_PROPERTY_ID_FIRST_NAME Name.", GetErrorMessage(r));
-
- r = contact.SetValue(CONTACT_PROPERTY_ID_MIDDLE_NAME, userProfile.GetValue(USER_PROFILE_PROPERTY_ID_MIDDLE_NAME));
- SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Failed to set USER_PROFILE_PROPERTY_ID_MIDDLE_NAME", GetErrorMessage(r));
-
- r = contact.SetValue(CONTACT_PROPERTY_ID_LAST_NAME, userProfile.GetValue(USER_PROFILE_PROPERTY_ID_LAST_NAME));
- SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Failed to set USER_PROFILE_PROPERTY_ID_LAST_NAME Name.", GetErrorMessage(r));
-
- r = contact.SetValue(CONTACT_PROPERTY_ID_NAME_PREFIX, userProfile.GetValue(USER_PROFILE_PROPERTY_ID_NAME_PREFIX));
- SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Failed to set USER_PROFILE_PROPERTY_ID_NAME_PREFIX Name.", GetErrorMessage(r));
-
- r = contact.SetValue(CONTACT_PROPERTY_ID_NAME_SUFFIX, userProfile.GetValue(USER_PROFILE_PROPERTY_ID_NAME_SUFFIX));
- SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Failed to set USER_PROFILE_PROPERTY_ID_NAME_SUFFIX Name.", GetErrorMessage(r));
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfilePhoneNumbers(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS));
- SysTryReturnResult(NID_SCL, pUserProfilePhoneNumbers, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_PHONE_NUMBERS .", GetErrorMessage(GetLastResult()));
-
- std::unique_ptr<IEnumerator> pEnum(pUserProfilePhoneNumbers->GetEnumeratorN());
- SysTryReturnResult(NID_SCL, pEnum, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- PhoneNumber* pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent());
- contact.AddPhoneNumber(*pPhoneNumber);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileEmails(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_EMAILS));
- SysTryReturnResult(NID_SCL, pUserProfileEmails, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_EMAILS .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileEmails->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- Email* pEmail = static_cast<Email*>(pEnum->GetCurrent());
- contact.AddEmail(*pEmail);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileUrls(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_URLS));
- SysTryReturnResult(NID_SCL, pUserProfileUrls, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_URLS .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileUrls->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- Url* pUrl = static_cast<Url*>(pEnum->GetCurrent());
- contact.AddUrl(*pUrl);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileAddresses(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_ADDRESSES));
- SysTryReturnResult(NID_SCL, pUserProfileAddresses, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_ADDRESSES .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileAddresses->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- Address* pAddress = static_cast<Address*>(pEnum->GetCurrent());
- contact.AddAddress(*pAddress);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileImAddresses(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_IMADDRESSES));
- SysTryReturnResult(NID_SCL, pUserProfileImAddresses, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_IMADDRESSES .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileImAddresses->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- ImAddress* pImAddress = static_cast<ImAddress*>(pEnum->GetCurrent());
- contact.AddImAddress(*pImAddress);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileEvents(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_EVENTS));
- SysTryReturnResult(NID_SCL, pUserProfileEvents, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_EVENTS .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileEvents->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- ContactEvent* pContactEvent = static_cast<ContactEvent*>(pEnum->GetCurrent());
- contact.AddEvent(*pContactEvent);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileOrganizations(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS));
- SysTryReturnResult(NID_SCL, pUserProfileOrganizations, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_ORGANIZATIONS .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileOrganizations->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- Organization* pOrganization = static_cast<Organization*>(pEnum->GetCurrent());
- contact.AddOrganization(*pOrganization);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileNotes(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_NOTES));
- SysTryReturnResult(NID_SCL, pUserProfileNotes, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_NOTES .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileNotes->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- String* pNote = static_cast<String*>(pEnum->GetCurrent());
- contact.AddNote(*pNote);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileNickNames(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_NICKNAMES));
- SysTryReturnResult(NID_SCL, pUserProfileNickNames, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_NICKNAMES .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileNickNames->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- String* pNickName = static_cast<String*>(pEnum->GetCurrent());
- contact.AddNickname(*pNickName);
- }
-
- std::unique_ptr<IList, AllElementsDeleter> pUserProfileRelationships(userProfile.GetValuesN(USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS));
- SysTryReturnResult(NID_SCL, pUserProfileRelationships, GetLastResult(), "[%s] Failed to get USER_PROFILE_MPROPERTY_ID_RELATIONSHIPS .", GetErrorMessage(GetLastResult()));
-
- pEnum.reset(pUserProfileRelationships->GetEnumeratorN());
- while (pEnum->MoveNext() == E_SUCCESS)
- {
- Relationship* pRelationship = static_cast<Relationship*>(pEnum->GetCurrent());
- contact.AddRelationship(*pRelationship);
- }
-
- return r;
-}
-
}} // Tizen::Social