diff options
author | Gwangbok Kim <gwangbok.kim@samsung.com> | 2013-08-05 22:43:33 +0900 |
---|---|---|
committer | Gwangbok Kim <gwangbok.kim@samsung.com> | 2013-08-05 22:43:33 +0900 |
commit | f44824eb498c64b11b9acb1125d485668fda31a2 (patch) | |
tree | 34cd1def109c0f75a536cecb37ab81b765283455 | |
parent | 0865e741a1d80bd942d69af4fa6697d51c51b166 (diff) | |
download | social-f44824eb498c64b11b9acb1125d485668fda31a2.tar.gz social-f44824eb498c64b11b9acb1125d485668fda31a2.tar.bz2 social-f44824eb498c64b11b9acb1125d485668fda31a2.zip |
fix N_SE-47241
Change-Id: I65677cf854411e06c82f6764bf912c4b4e39a98b
Signed-off-by: Gwangbok Kim <gwangbok.kim@samsung.com>
-rw-r--r-- | src/FScl_AddressbookImpl.cpp | 43 | ||||
-rw-r--r-- | src/FScl_AddressbookManagerImpl.cpp | 39 |
2 files changed, 81 insertions, 1 deletions
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 <contacts.h> #include <unique_ptr.h> +#include <FApp.h> #include <FBaseColIListT.h> #include <FBaseColArrayListT.h> #include <FBaseResult.h> #include <FBaseLongLong.h> #include <FBaseInteger.h> +#include <FIoFile.h> #include <FSclContact.h> #include <FSclCategory.h> #include <FSclUserProfile.h> @@ -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<char[]> 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 <contacts.h> #include <unique_ptr.h> +#include <FApp.h> #include <FBaseColIListT.h> #include <FBaseColArrayListT.h> #include <FBaseColHashMapT.h> @@ -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<char[]> 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)); |