[DCM-1014] ExportUserProfileToVcardStreamN() does not convert thumbnail property
authorJaehwa Shin <jaehwa.shin@samsung.com>
Fri, 22 Mar 2013 01:42:23 +0000 (10:42 +0900)
committerJaehwa Shin <jaehwa.shin@samsung.com>
Fri, 22 Mar 2013 01:42:23 +0000 (10:42 +0900)
Change-Id: If30908d4dd0be4ed419cb30c14d78750bcae1161
Signed-off-by: Jaehwa Shin <jaehwa.shin@samsung.com>
src/FScl_AddressbookManagerImpl.cpp
src/FScl_AddressbookUtil.cpp
src/FScl_AddressbookUtil.h

index bb63aa6..f2ff99f 100644 (file)
@@ -1964,15 +1964,11 @@ _AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& user
 
        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));
@@ -1982,7 +1978,7 @@ _AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& user
        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()));
@@ -2021,17 +2017,13 @@ _AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Col
 
        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));
@@ -2064,15 +2056,11 @@ _AddressbookManagerImpl::ExportUserProfileToVcard(const UserProfile& userProfile
        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));
 
@@ -2107,17 +2095,13 @@ _AddressbookManagerImpl::ExportUserProfilesToVcard(const Tizen::Base::Collection
 
        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));
 
index 69ed82b..e2edcd1 100644 (file)
@@ -869,129 +869,4 @@ _AddressbookUtil::Search(const Tizen::Base::String& keyword)
        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
index 8f1bff3..deda6f8 100644 (file)
@@ -641,8 +641,6 @@ public:
 
        static Person* CreatePersonN(void);
 
-       static result ConvertUserProfileToContact(const UserProfile& userProfile, Contact& contact);
-
        template<typename __View, typename ChangeInfo>
        static Tizen::Base::Collection::IList* SearchWithVersionN(int addressbookId, int currentVersion, int& latestVersion)
        {