SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(_AddressbookUtil::GetContactRecordN(_contacts_simple_contact._uri, contactId));
- SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
int intValue = 0;
contacts_record_get_int(pContactRecord.get(), _contacts_simple_contact.id, &intValue);
SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
pContactRecord.reset(_AddressbookUtil::GetContactRecordN(_contacts_contact._uri, contact.GetRecordId()));
- SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+ SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
_ContactImpl::GetInstance(*const_cast<Contact*>(&contact))->SetContactRecordHandle(pContactRecord.release());
}
result r = _AddressbookUtil::UpdateContactRecords(listHandle);
- SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
contacts_list_destroy(listHandle, false);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
return E_SUCCESS;
}
ret = contacts_record_clone(recordHandle, &newRecordHandle);
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));
- ret = contacts_record_set_int(newRecordHandle, _contacts_my_profile.address_book_id, __addressbookId);
- if (ret != CONTACTS_ERROR_NONE)
- {
- contacts_record_destroy(newRecordHandle, true);
- SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- return E_SYSTEM;
- }
+ unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(newRecordHandle);
+ SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+
+ ret = contacts_record_set_int(pContactRecord.get(), _contacts_my_profile.address_book_id, __addressbookId);
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
int recordId = 0;
- result r = _AddressbookUtil::InsertContactRecordN(newRecordHandle, recordId);
+ result r = _AddressbookUtil::InsertContactRecordN(pContactRecord.get(), recordId);
SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
else if (recordId > 0)
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));
result r = _AddressbookUtil::UpdateContactRecord(newRecordHandle);
- SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
contacts_record_destroy(newRecordHandle, true);
+ SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
else
{
SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
- contacts_record_h newRecordHandle = null;
- ret = contacts_record_create(_contacts_my_profile._uri, &newRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
- r = CopyMyProfileContents(recordHandle, newRecordHandle);
- if (r != E_SUCCESS)
- {
- contacts_record_destroy(newRecordHandle, true);
- SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- return E_OUT_OF_MEMORY;
-
- }
+ unique_ptr<ContactRecord, ContactRecordDeleter> pContactRecord(CopyMyProfileRecordHandle(recordHandle));
+ SysTryReturn(NID_SCL, pContactRecord != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
- ret = contacts_record_set_int(newRecordHandle, _contacts_my_profile.address_book_id, __addressbookId);
- if (ret != CONTACTS_ERROR_NONE)
- {
- contacts_record_destroy(newRecordHandle, true);
- SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
- return E_SYSTEM;
- }
+ ret = contacts_record_set_int(pContactRecord.get(), _contacts_my_profile.address_book_id, __addressbookId);
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
int recordId = 0;
- result r = _AddressbookUtil::InsertContactRecordN(newRecordHandle, recordId);
+
+ r = _AddressbookUtil::InsertContactRecordN(pContactRecord.get(), recordId);
SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
}
}
return false;
}
-result
-_AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_record_h dstHandle)
+contacts_record_h
+_AddressbookImpl::CopyMyProfileRecordHandle(contacts_record_h srcHandle)
{
+ ClearLastResult();
+
int ret = CONTACTS_ERROR_NONE;
int intValue = 0;
unsigned int count = 0;
unsigned int i = 0;
char* pCharValue = null;
+ contacts_record_h contactHandle = null;
contacts_record_h srcRecordHandle = null;
contacts_record_h dstRecordHandle = null;
+ ret = contacts_record_create(_contacts_my_profile._uri, &contactHandle);
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
// name
contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.name, &count);
if (count > 0)
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.name, 0, &srcRecordHandle);
ret = contacts_record_create(_contacts_name._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle nameHandle(dstRecordHandle);
- contacts_record_get_str(srcRecordHandle, _contacts_name.first, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.first, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.first, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.last, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.last, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.last, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.addition, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.addition, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.addition, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.suffix, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.suffix, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.suffix, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.prefix, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.prefix, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.prefix, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_first, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_first, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_first, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_middle, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_middle, pCharValue);
- contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_last, &pCharValue);
+ contacts_record_get_str_p(srcRecordHandle, _contacts_name.phonetic_last, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_last, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.name, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.name, dstRecordHandle);
nameHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.company, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_company._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle companyHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_company.phonetic_name, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_company.phonetic_name, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.company, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.company, dstRecordHandle);
companyHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.note, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_note._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle noteHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_note.note, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_note.note, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.note, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.note, dstRecordHandle);
noteHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.number, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_number._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle numberHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_number.number, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_number.number, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.number, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.number, dstRecordHandle);
numberHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.email, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_email._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle emailHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_email.email, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_email.email, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.email, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.email, dstRecordHandle);
emailHandle.Release();
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.event, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_event._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle eventHandle(dstRecordHandle);
contacts_record_get_int(srcRecordHandle, _contacts_event.date, &intValue);
contacts_record_set_int(dstRecordHandle, _contacts_event.date, intValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.event, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.event, dstRecordHandle);
eventHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.messenger, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_messenger._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle imAddressHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_messenger.im_id, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_messenger.im_id, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.messenger, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.messenger, dstRecordHandle);
imAddressHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.address, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_address._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle addressHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_address.country, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_address.country, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.address, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.address, dstRecordHandle);
addressHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.url, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_url._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle urlHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_url.url, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_url.url, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.url, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.url, dstRecordHandle);
urlHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.nickname, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_nickname._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle nicknameHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_nickname.name, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_nickname.name, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.nickname, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.nickname, dstRecordHandle);
nicknameHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.relationship, i, &srcRecordHandle);
ret = contacts_record_create(_contacts_relationship._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle relationshipHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_relationship.name, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_relationship.name, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_my_profile.relationship, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_my_profile.relationship, dstRecordHandle);
relationshipHandle.Release();
}
contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.image, 0, &srcRecordHandle);
ret = contacts_record_create(_contacts_image._uri, &dstRecordHandle);
- SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__ContactsRecordHandle imageHandle(dstRecordHandle);
contacts_record_get_str_p(srcRecordHandle, _contacts_image.path, &pCharValue);
contacts_record_set_str(dstRecordHandle, _contacts_image.path, pCharValue);
- contacts_record_add_child_record(dstHandle, _contacts_contact.image, dstRecordHandle);
+ contacts_record_add_child_record(contactHandle, _contacts_contact.image, dstRecordHandle);
imageHandle.Release();
}
- return E_SUCCESS;
+ return contactHandle;
}
contacts_record_h