From: Gwangbok Kim Date: Mon, 5 Aug 2013 13:43:33 +0000 (+0900) Subject: fix N_SE-47241 X-Git-Tag: submit/tizen_2.2/20131107.062123~28 X-Git-Url: http://review.tizen.org/git/?p=framework%2Fosp%2Fsocial.git;a=commitdiff_plain;h=f44824eb498c64b11b9acb1125d485668fda31a2 fix N_SE-47241 Change-Id: I65677cf854411e06c82f6764bf912c4b4e39a98b Signed-off-by: Gwangbok Kim --- diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp index c747495..8bb083a 100644 --- a/src/FScl_AddressbookImpl.cpp +++ b/src/FScl_AddressbookImpl.cpp @@ -21,11 +21,13 @@ */ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -54,6 +56,7 @@ using namespace Tizen::App; using namespace Tizen::Base; using namespace Tizen::Base::Collection; using namespace Tizen::Graphics; +using namespace Tizen::Io; namespace Tizen { namespace Social { @@ -481,7 +484,7 @@ _AddressbookImpl::UpdateContact(const Contact& contact) int imageId = -1; int imageId2 = -1; - for (int i = count2 - 1; i >= 0; i--) + for (unsigned int i = count2 - 1; i >= 0; i--) { contacts_record_get_child_record_at_p(recordHandle, _contacts_contact.image, i, &imageHandle); contacts_record_get_int(imageHandle, _contacts_image.id, &imageId); @@ -514,8 +517,46 @@ _AddressbookImpl::UpdateContact(const Contact& contact) contacts_record_h copyRecordHandle = CopyContactRecordHandle(recordHandle); SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + contacts_record_h tempHandle = null; + contacts_record_get_child_record_count(copyRecordHandle, _contacts_contact.image, &count); + + char* pCharValue = null; + String tempPath; + + for (unsigned int i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(copyRecordHandle, _contacts_contact.image, i, &tempHandle); + contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue); + + tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp"; + tempPath.Append((int)i); + tempPath.Append(L".jpg"); + String servicePath(pCharValue); + + File::Copy(servicePath, tempPath, true); + + std::unique_ptr pCharArray( _StringConverter::CopyToCharArrayN(tempPath)); + SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + contacts_record_set_str(tempHandle, _contacts_image.path, pCharArray.get()); + contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue); + + tempPath.Clear(); + } + ret = contacts_db_replace_record(copyRecordHandle, contactId); contacts_record_destroy(copyRecordHandle, true); + + for (unsigned int i = 0; i < count; i++) + { + tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp"; + tempPath.Append((int)i); + tempPath.Append(L".jpg"); + + File::Remove(tempPath); + + tempPath.Clear(); + } } 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)); diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp index cd96957..1bb2e1b 100644 --- a/src/FScl_AddressbookManagerImpl.cpp +++ b/src/FScl_AddressbookManagerImpl.cpp @@ -21,6 +21,7 @@ */ #include #include +#include #include #include #include @@ -540,8 +541,46 @@ _AddressbookManagerImpl::UpdateContact(const Contact& contact) contacts_record_h copyRecordHandle = CopyContactRecordHandle(recordHandle); SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + contacts_record_h tempHandle = null; + contacts_record_get_child_record_count(copyRecordHandle, _contacts_contact.image, &count); + + char* pCharValue = null; + String tempPath; + + for (int i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(copyRecordHandle, _contacts_contact.image, i, &tempHandle); + contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue); + + tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp"; + tempPath.Append(i); + tempPath.Append(L".jpg"); + String servicePath(pCharValue); + + File::Copy(servicePath, tempPath, true); + + std::unique_ptr pCharArray( _StringConverter::CopyToCharArrayN(tempPath)); + SysTryReturnResult(NID_SCL, pCharArray != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + contacts_record_set_str(tempHandle, _contacts_image.path, pCharArray.get()); + contacts_record_get_str(tempHandle, _contacts_image.path, &pCharValue); + + tempPath.Clear(); + } + ret = contacts_db_replace_record(copyRecordHandle, contactId); contacts_record_destroy(copyRecordHandle, true); + + for (int i = 0; i < count; i++) + { + tempPath = Tizen::App::App::GetInstance()->GetAppRootPath() + L"data/temp"; + tempPath.Append(i); + tempPath.Append(L".jpg"); + + File::Remove(tempPath); + + tempPath.Clear(); + } } 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));