SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. account id is invalid.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_SCL, !name.IsEmpty(), null, E_INVALID_ARG, "[%s] Invalid argument is used. The name is empty.", GetErrorMessage(E_INVALID_ARG));
+ ClearLastResult();
+
result r = E_SUCCESS;
int ret = CONTACTS_ERROR_NONE;
int recordId = 0;
SysTryReturn(NID_SCL, accountId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. accountId = %d.", GetErrorMessage(E_INVALID_ARG), accountId);
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
__Filter<__ContactsAddressbook> filter;
filter.Construct();
filter.AddInt(_contacts_address_book.account_id, CONTACTS_MATCH_EQUAL, accountId);
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
__Query<__ContactsAddressbook> query;
query.Construct();
query.SetSort(_contacts_address_book.name, true);
SysTryReturn(NID_SCL, addressbookId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. addressbookId.", GetErrorMessage(E_INVALID_ARG), addressbookId);
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
result r = E_SUCCESS;
int ret = CONTACTS_ERROR_NONE;
contacts_record_h addressbookHandle = null;
r = pAddressbook->Construct();
SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
ret = contacts_db_get_record(_contacts_address_book._uri, addressbookId, &addressbookHandle);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, null, E_OBJ_NOT_FOUND, "[%s] The addressbook %d is not found.", GetErrorMessage(E_OBJ_NOT_FOUND), addressbookId);
SysTryReturn(NID_SCL, !_ContactImpl::GetInstance(contact)->IsEmpty(), E_INVALID_ARG, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact does not have any property.", GetErrorMessage(E_INVALID_ARG));
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
int recordId = 0;
contacts_record_h recordHandle = null;
_AddressbookManagerImpl::GetCategoriesByContactN(RecordId contactId) const
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. The specified contact is invalid.", GetErrorMessage(E_INVALID_ARG));
ClearLastResult();
_AddressbookManagerImpl::GetContactN(RecordId contactId) const
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
SysTryReturn(NID_SCL, contactId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[%s] Invalid argument is used. contactId = %d.", GetErrorMessage(E_INVALID_ARG), contactId);
+ ClearLastResult();
+
int intValue = 0;
contacts_record_h contactHandle = null;
_AddressbookManagerImpl::GetPersonN(PersonId personId) const
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
SysTryReturn(NID_SCL, personId >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. personId = %d.", GetErrorMessage(E_INVALID_ARG), personId);
contacts_record_h recordHandle = null;
+ ClearLastResult();
+
int intValue = 0;
int ret = contacts_db_get_record(_contacts_person._uri, personId, &recordHandle);
SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
SysTryReturn(NID_SCL, categoryId != INVALID_RECORD_ID, null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. categoryId = %d.", categoryId);
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
-
contacts_record_h recordHandle = null;
ClearLastResult();
SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid arguent is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version);
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(-1, version, latestVersion);
SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
_AddressbookManagerImpl::SearchPersonsN(const Tizen::Base::String& keyword) const
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ SysTryReturn(NID_SCL, !keyword.IsEmpty(), null, E_INVALID_ARG, "Invalid argument is used. keyword is empty string.", GetErrorMessage(E_INVALID_ARG));
+
+ ClearLastResult();
contacts_record_h currentRecord = null;
std::unique_ptr<Person> pPerson(null);
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
IList* pList = null;
bool ascending = false;
unsigned int viewSortPropertyId = 0;
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, -1, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
int count = 0;
AddressbookFilterType type = _AddressbookFilterImpl::GetInstance(filter)->GetType();
contacts_filter_h filterHandle = _AddressbookFilterImpl::GetInstance(filter)->GetFilterHandle();
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
contacts_record_h recordHandle = _ContactImpl::GetInstance(contact)->GetContactRecordHandle();
char* pVcardStream = null;
ret = contacts_vcard_make_from_contact(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<char> pChar(pVcardStream);
-
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));
+ if (pByteBuffer == null)
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- 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));
+ return null;
+ }
+
+ result r = pByteBuffer->Construct(strlen(pVcardStream));
+ if (IsFailed(r))
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
- r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+ r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+ free(pVcardStream);
SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
char* pVcardStream = null;
int ret = CONTACTS_ERROR_NONE;
Contact* pContact = null;
int capacity = 0;
contacts_record_h recordHandle = null;
- std::unique_ptr<char> pChar(null);
std::unique_ptr<IEnumerator> pEnum(contactList.GetEnumeratorN());
SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
ret = contacts_vcard_make_from_contact(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));
- pChar.reset(pVcardStream);
-
- capacity += strlen(pChar.get());
+ capacity += strlen(pVcardStream);
r = pByteBuffer->ExpandCapacity(capacity);
- SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (IsFailed(r))
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
- r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+ r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+ free(pVcardStream);
+ pVcardStream = null;
SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
}
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
int ret = CONTACTS_ERROR_NONE;
contacts_record_h personRecordHandle = null;
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_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- std::unique_ptr<char> pChar(pVcardStream);
-
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));
+ if (pByteBuffer == null)
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- 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));
+ return null;
+ }
+
+ result r = pByteBuffer->Construct(strlen(pVcardStream));
+ if (IsFailed(r))
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
- r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+ r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+ free(pVcardStream);
SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
return pByteBuffer.release();
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
int ret = CONTACTS_ERROR_NONE;
Person* pPerson = null;
char* pVcardStream = null;
contacts_record_h personRecordHandle = null;
__ContactsRecordHandle recordHandle(null);
- std::unique_ptr<char> pChar(null);
std::unique_ptr<IEnumerator> pEnum(personList.GetEnumeratorN());
SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
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_NONE, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- pChar.reset(pVcardStream);
-
- capacity += strlen(pChar.get());
+ capacity += strlen(pVcardStream);
r = pByteBuffer->ExpandCapacity(capacity);
- SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (IsFailed(r))
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
- r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+ r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+ free(pVcardStream);
+ pVcardStream = null;
SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
}
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
contacts_list_h listHandle = null;
result r = E_SUCCESS;
contacts_list_get_count(listHandle, &count);
std::unique_ptr<ArrayList, AllElementsDeleter> pList(new (std::nothrow) ArrayList());
- SysTryReturn(NID_SCL, pList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (pList == null)
+ {
+ contacts_list_destroy(listHandle, true);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
r = pList->Construct(count);
- SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (IsFailed(r))
+ {
+ contacts_list_destroy(listHandle, true);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- for (int i = 0; i < count; i++)
+ return null;
+ }
+
+ for (unsigned int i = 0; i < count; i++)
{
std::unique_ptr<Contact> pContact(new (std::nothrow) Contact());
- SysTryReturn(NID_SCL, pContact != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (pContact == null)
+ {
+ contacts_list_destroy(listHandle, true);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- contacts_list_get_current_record_p(listHandle, &recordHandle);
+ return null;
+ }
- _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(recordHandle);
r = pList->Add(pContact.get());
- SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (IsFailed(r))
+ {
+ contacts_list_destroy(listHandle, true);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
pContact.release();
+ }
+
+ std::unique_ptr<IEnumerator> pEnum(pList->GetEnumeratorN());
+
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ Contact* pContact = static_cast <Contact*> (pEnum->GetCurrent());
+
+ contacts_list_get_current_record_p(listHandle, &recordHandle);
+ _ContactImpl::GetInstance(*pContact)->SetContactRecordHandle(recordHandle);
ret = contacts_list_next(listHandle);
- if (ret != CONTACTS_ERROR_NONE)
- {
- break;
- }
}
+ contacts_list_destroy(listHandle, false);
+
return pList.release();
}
-Tizen::Base::ByteBuffer*
+ByteBuffer*
_AddressbookManagerImpl::ExportUserProfileToVcardStreamN(const UserProfile& userProfile)
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
char* pVcardStream = null;
int ret = CONTACTS_ERROR_NONE;
contacts_record_h recordHandle = null;
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<char> pChar(pVcardStream);
-
std::unique_ptr<ByteBuffer> pByteBuffer(new (std::nothrow) ByteBuffer);
+ if (pByteBuffer == null)
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
SysTryReturn(NID_SCL, pByteBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- 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));
+ result r = pByteBuffer->Construct(strlen(pVcardStream));
+ if (IsFailed(r))
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ return null;
+ }
- r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pChar.get()), 0, strlen(pChar.get()));
+ r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+ free(pVcardStream);
SysTryReturn(NID_SCL, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
return pByteBuffer.release();
}
-Tizen::Base::ByteBuffer*
+ByteBuffer*
_AddressbookManagerImpl::ExportUserProfilesToVcardStreamN(const Tizen::Base::Collection::IList& userProfileList)
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ ClearLastResult();
+
char* pVcardStream = null;
int ret = CONTACTS_ERROR_NONE;
UserProfile* pProfile = null;
result r = E_SUCCESS;
int capacity = 0;
- std::unique_ptr<char> pChar(null);
-
std::unique_ptr<IEnumerator> pEnum(userProfileList.GetEnumeratorN());
SysTryReturn(NID_SCL, pEnum != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
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));
- pChar.reset(pVcardStream);
-
- capacity += strlen(pChar.get());
+ capacity += strlen(pVcardStream);
r = pByteBuffer->ExpandCapacity(capacity);
- SysTryReturn(NID_SCL, !IsFailed(r), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ if (IsFailed(r))
+ {
+ free(pVcardStream);
+ SysLogException(NID_SCL, 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()));
+ return null;
+ }
+
+ r = pByteBuffer->SetArray(reinterpret_cast<byte*>(pVcardStream), 0, strlen(pVcardStream));
+ free(pVcardStream);
SysTryReturn(NID_SCL, r == E_SUCCESS, null, E_SYSTEM, "[%s] A system error has been occurred.: capacity(%d), size(%d)", GetErrorMessage(E_SYSTEM));
}
return E_SUCCESS;
}
-Tizen::Base::Collection::IList*
+IList*
_AddressbookManagerImpl::GetAllUserProfilesN(void) const
{
SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));