}
PlatformResult ErrorChecker(int err, const char* message) {
+ LoggerD("Enter");
if (CONTACTS_ERROR_NONE != err) {
LoggerE("%s, error code: %i", message, err);
return PlatformResult(ErrorCode::UNKNOWN_ERR, message);
PlatformResult GetStrFromRecord(contacts_record_h record,
unsigned int property_id, char** value) {
+ LoggerD("Enter");
int err = contacts_record_get_str_p(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
LoggerE("Error during getting contact record, error code: %i", err);
PlatformResult GetIntFromRecord(contacts_record_h record,
unsigned int property_id, int* value) {
+ LoggerD("Enter");
int err = contacts_record_get_int(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
LoggerE("Error during getting contact record, error code: %i", err);
PlatformResult GetBoolFromRecord(contacts_record_h record,
unsigned int property_id, bool* value) {
+ LoggerD("Enter");
int err = contacts_record_get_bool(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
LoggerE("Error during getting contact record, error code: %i", err);
PlatformResult SetStrInRecord(contacts_record_h record,
unsigned int property_id, const char* value) {
+ LoggerD("Enter");
int err = contacts_record_set_str(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
LoggerE("Error during setting str contact record property, error code: %i",
PlatformResult SetIntInRecord(contacts_record_h record,
unsigned int property_id, int value) {
+ LoggerD("Enter");
int err = contacts_record_set_int(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
LoggerE("Error during getting contact record, error code: %i", err);
PlatformResult SetBoolInRecord(contacts_record_h record,
unsigned int property_id, bool value) {
+ LoggerD("Enter");
int err = contacts_record_set_bool(record, property_id, value);
if (CONTACTS_ERROR_NONE != err) {
LoggerE("Error during getting contact record, error code: %i", err);
PlatformResult ClearAllContactRecord(contacts_record_h contacts_record,
unsigned int property_id) {
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
int record_count;
PlatformResult status =
GetNumberOfChildRecord(contacts_record, property_id, &record_count);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
for (unsigned int i = 0; i < record_count; ++i) {
unsigned int actual_index = record_count - 1 - i;
contacts_record, property_id, actual_index, &phone_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Error during getting phone record");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
err = contacts_record_remove_child_record(contacts_record, property_id,
phone_record);
status =
ContactUtil::ErrorChecker(err, "Error during getting phone record");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
return PlatformResult(ErrorCode::NO_ERROR);
PlatformResult GetNumberOfChildRecord(contacts_record_h contacts_record,
unsigned int property_id,
int* child_count) {
+ LoggerD("Enter");
assert(child_count);
int err = CONTACTS_ERROR_NONE;
PlatformResult ImportContactNameFromContactsRecord(
contacts_record_h contacts_record, JsonObject* out_ptr,
bool* is_contact_name) {
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
if (!contacts_record) {
LoggerW("Contacts record is null");
_contacts_contact.name, &count);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Contacts child record get count error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (count > 1) {
LoggerE("More than one ContactName for one Contact");
contacts_record, _contacts_contact.name, 0, &contact_name);
status =
ContactUtil::ErrorChecker(err, "Contacts name record get childerror");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Documentation says:
// child_record MUST NOT be released by you.
char* char_value = nullptr;
status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.prefix,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("prefix",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.suffix,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("suffix",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.first,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("firstName",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.addition,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("middleName",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(contact_name, _contacts_name.last,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("lastName",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(
contact_name, _contacts_name.phonetic_first, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("phoneticFirstName",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(
contact_name, _contacts_name.phonetic_middle, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("phoneticMiddleName",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(
contact_name, _contacts_name.phonetic_last, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("phoneticLastName",
char_value ? JsonValue{char_value} : JsonValue{}));
contacts_record, _contacts_contact.nickname, &count);
status =
ContactUtil::ErrorChecker(err, "Contacts child record get count error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
JsonArray nicknames;
for (unsigned int i = 0; i < count; ++i) {
contacts_record, _contacts_contact.nickname, i, &nickname);
status = ContactUtil::ErrorChecker(
err, "Contacts nicknames record get child error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
status = ContactUtil::GetStrFromRecord(nickname, _contacts_nickname.name,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (char_value) {
nicknames.push_back(JsonValue{char_value});
PlatformResult ExportContactNameToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_name._uri, &contact_name);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Contacts record create error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
update = false;
}
PlatformResult status =
ContactUtil::SetStrInRecord(*contacts_name_ptr, _contacts_name.prefix,
FromJson<JsonString>(in, "prefix").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "suffix")) {
PlatformResult status =
ContactUtil::SetStrInRecord(*contacts_name_ptr, _contacts_name.suffix,
FromJson<JsonString>(in, "suffix").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "firstName")) {
PlatformResult status = ContactUtil::SetStrInRecord(
*contacts_name_ptr, _contacts_name.first,
FromJson<JsonString>(in, "firstName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "middleName")) {
PlatformResult status = ContactUtil::SetStrInRecord(
*contacts_name_ptr, _contacts_name.addition,
FromJson<JsonString>(in, "middleName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "lastName")) {
PlatformResult status = ContactUtil::SetStrInRecord(
*contacts_name_ptr, _contacts_name.last,
FromJson<JsonString>(in, "lastName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "phoneticFirstName")) {
PlatformResult status = ContactUtil::SetStrInRecord(
*contacts_name_ptr, _contacts_name.phonetic_first,
FromJson<JsonString>(in, "phoneticFirstName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "phoneticMiddleName")) {
PlatformResult status = ContactUtil::SetStrInRecord(
*contacts_name_ptr, _contacts_name.phonetic_middle,
FromJson<JsonString>(in, "phoneticMiddleName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "phoneticLastName")) {
PlatformResult status = ContactUtil::SetStrInRecord(
*contacts_name_ptr, _contacts_name.phonetic_last,
FromJson<JsonString>(in, "phoneticLastName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// contact_name is being added as a child to contacts_record
contacts_record, _contacts_contact.name, *contacts_name_ptr);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Contacts record add child error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// and now unique_ptr can be released - contacts_name is protected
// by its parent (contacts_record)
err = contacts_record_create(_contacts_nickname._uri, &nickname_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Contacts record create error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
update = false;
}
PlatformResult status =
ContactUtil::SetStrInRecord(*nickname_ptr, _contacts_nickname.name,
JsonCast<JsonString>(nickname).c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!update) {
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.nickname, *nickname_ptr);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Contacts record add child error");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// Do not delete record, it is passed to the platform
nickname_ptr.release();
PlatformResult ImportContactEmailAddressFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
char* email = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_email.email, &email);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!email) {
return PlatformResult(ErrorCode::NO_ERROR);
bool is_default = false;
status = ContactUtil::GetBoolFromRecord(
child_record, _contacts_email.is_default, &is_default);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("isDefault", JsonValue{is_default}));
char* label = nullptr;
status = ContactUtil::GetStrFromRecord(child_record, _contacts_email.label,
&label);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("label", label ? JsonValue{label} : JsonValue{}));
int type = 0;
status =
ContactUtil::GetIntFromRecord(child_record, _contacts_email.type, &type);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
JsonArray types;
if (type & CONTACTS_EMAIL_TYPE_HOME) {
PlatformResult ExportContactEmailAddressToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
contacts_record_h c_email_record_h = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
err = contacts_record_create(_contacts_email._uri, &c_email_record_h);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Failed to create email record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&c_email_record_h, ContactsDeleter);
status =
ContactUtil::SetStrInRecord(c_email_record_h, _contacts_email.email,
FromJson<JsonString>(in, "email").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
status =
ContactUtil::SetBoolInRecord(c_email_record_h, _contacts_email.is_default,
FromJson<bool>(in, "isDefault"));
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!IsNull(in, "label")) {
status =
ContactUtil::SetStrInRecord(c_email_record_h, _contacts_email.label,
FromJson<JsonString>(in, "label").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
int type_to_set = 0;
}
status = ContactUtil::SetIntInRecord(c_email_record_h, _contacts_email.type,
type_to_set);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.email, c_email_record_h);
status =
ContactUtil::ErrorChecker(err, "Fail to save email record into database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactPhoneNumberFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
contacts_record_h child_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
char* phone = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_number.number, &phone);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("number", JsonValue{phone}));
bool is_default = false;
status = ContactUtil::GetBoolFromRecord(
child_record, _contacts_number.is_default, &is_default);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("isDefault", JsonValue{is_default}));
int type = 0;
status =
ContactUtil::GetIntFromRecord(child_record, _contacts_number.type, &type);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
JsonArray types;
if (type & CONTACTS_NUMBER_TYPE_HOME) {
char* label = nullptr;
status = ContactUtil::GetStrFromRecord(child_record, _contacts_number.label,
&label);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out["label"] = label ? JsonValue{label} : JsonValue{};
PlatformResult ExportContactPhoneNumberToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
contacts_record_h phone_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
int err = contacts_record_create(_contacts_number._uri, &phone_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Fail to create phone_record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&phone_record, ContactsDeleter);
status =
ContactUtil::SetStrInRecord(phone_record, _contacts_number.number,
FromJson<JsonString>(in, "number").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
status =
ContactUtil::SetBoolInRecord(phone_record, _contacts_number.is_default,
FromJson<bool>(in, "isDefault"));
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!IsNull(in, "label")) {
status =
ContactUtil::SetStrInRecord(phone_record, _contacts_address.label,
FromJson<JsonString>(in, "label").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
int type_to_set = 0;
status = ContactUtil::SetIntInRecord(phone_record, _contacts_number.type,
type_to_set);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.number, phone_record);
status = ContactUtil::ErrorChecker(
err, "Fail to set number value to phone_record");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactOrganizationFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
char* char_value = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_company.name, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("name", char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(
child_record, _contacts_company.department, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("department",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(
child_record, _contacts_company.job_title, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("title",
char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record, _contacts_company.role,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("role", char_value ? JsonValue{char_value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record, _contacts_company.logo,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("logoURI",
char_value ? JsonValue{char_value} : JsonValue{}));
PlatformResult ExportContactOrganizationToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_company._uri, &organization_record);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Failed to create organization record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&organization_record, ContactsDeleter);
status =
ContactUtil::SetStrInRecord(organization_record, _contacts_company.name,
FromJson<JsonString>(in, "name").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "department")) {
status = ContactUtil::SetStrInRecord(
organization_record, _contacts_company.department,
FromJson<JsonString>(in, "department").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "title")) {
status = ContactUtil::SetStrInRecord(
organization_record, _contacts_company.job_title,
FromJson<JsonString>(in, "title").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "role")) {
status =
ContactUtil::SetStrInRecord(organization_record, _contacts_company.role,
FromJson<JsonString>(in, "role").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "logoURI")) {
std::string path =
ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "logoURI"));
status = ContactUtil::SetStrInRecord(organization_record,
_contacts_company.logo, path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.company, organization_record);
status = ContactUtil::ErrorChecker(
err, "Fail to set company value to child_record");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactWebSiteFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
char* char_value = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_url.url, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair(std::string("logoURI"),
picojson::value(char_value ? char_value : "")));
int type = 0;
status =
ContactUtil::GetIntFromRecord(child_record, _contacts_url.type, &type);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair(std::string("logoURI"),
picojson::value((CONTACTS_URL_TYPE_HOME == type)
PlatformResult ExportContactWebSiteToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_url._uri, &website_record_h);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Fail to create website record in database.");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&website_record_h, ContactsDeleter);
status = ContactUtil::SetStrInRecord(website_record_h, _contacts_url.url,
url.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
int type_to_set =
(FromJson<JsonString>(in, "type") == kContactWebSiteTypeHomePage)
status = ContactUtil::SetIntInRecord(website_record_h, _contacts_url.type,
type_to_set);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
err = contacts_record_add_child_record(contacts_record, _contacts_contact.url,
website_record_h);
status = ContactUtil::ErrorChecker(
err, "Problem during saving WebSite urls into database.");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactAnniversariesFromContactsRecord(
contacts_record_h contacts_record, unsigned int index, JsonObject* out_ptr,
bool* ret) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
int value = 0;
PlatformResult status =
ContactUtil::GetIntFromRecord(child_record, _contacts_event.type, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (CONTACTS_EVENT_TYPE_BIRTH == value) {
*ret = false;
if (CONTACTS_EVENT_TYPE_ANNIVERSARY == value) {
status = ContactUtil::GetIntFromRecord(child_record, _contacts_event.date,
&value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("date", JsonValue{static_cast<double>(value)}));
char* label = nullptr;
status = ContactUtil::GetStrFromRecord(child_record, _contacts_event.label,
&label);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("label", label ? JsonValue{label} : JsonValue{}));
}
PlatformResult ExportContactAnniversariesToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_event._uri, &anniversary_record);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Failed to create anniversary record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&anniversary_record, ContactsDeleter);
status = ContactUtil::SetIntInRecord(anniversary_record, _contacts_event.type,
CONTACTS_EVENT_TYPE_ANNIVERSARY);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
status = ContactUtil::SetIntInRecord(anniversary_record, _contacts_event.date,
date);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!IsNull(in, "label")) {
status =
ContactUtil::SetStrInRecord(anniversary_record, _contacts_event.label,
FromJson<JsonString>(in, "label").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.event, anniversary_record);
status = ContactUtil::ErrorChecker(
err, "Fail to save anniversary record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactRelationshipFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
char* relative = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_relationship.name, &relative);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!relative) {
return PlatformResult(ErrorCode::NO_ERROR);
int type = 0;
status = ContactUtil::GetIntFromRecord(child_record,
_contacts_relationship.type, &type);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// TODO Move out.insert outside of switch statement.
switch (type) {
char* label = nullptr;
status = ContactUtil::GetStrFromRecord(child_record,
_contacts_relationship.label, &label);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair(std::string("label"),
PlatformResult ExportContactRelationshipToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_relationship._uri, &child_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Fail to create child_record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&child_record, ContactsDeleter);
status = ContactUtil::SetStrInRecord(
child_record, _contacts_relationship.name,
FromJson<JsonString>(in, "relativeName").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
const JsonString& type = FromJson<JsonString>(in, "type");
int type_to_set;
status = ContactUtil::SetIntInRecord(
child_record, _contacts_relationship.type, type_to_set);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!IsNull(in, "label")) {
status =
ContactUtil::SetStrInRecord(child_record, _contacts_relationship.label,
FromJson<JsonString>(in, "label").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.relationship, child_record);
status = ContactUtil::ErrorChecker(
err, "Fail to set number value to child_record");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
record.release();
PlatformResult ImportContactInstantMessengerFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
char* im_address = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_messenger.im_id, &im_address);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!im_address) {
LoggerW("Skipping message with index %i. missing im address", index);
int type = 0;
status = ContactUtil::GetIntFromRecord(child_record, _contacts_messenger.type,
&type);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// TODO Move out.insert outside of switch statement.
switch (type) {
char* label = nullptr;
status = ContactUtil::GetStrFromRecord(child_record,
_contacts_messenger.label, &label);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("label", label ? JsonValue{label} : JsonValue{}));
PlatformResult ExportContactInstantMessengerToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_messenger._uri, &child_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Fail to create child_record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&child_record, ContactsDeleter);
status = ContactUtil::SetStrInRecord(
child_record, _contacts_messenger.im_id,
FromJson<JsonString>(in, "imAddress").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
int type_to_set = 0;
const JsonString& type = FromJson<JsonString>(in, "type");
status = ContactUtil::SetIntInRecord(child_record, _contacts_messenger.type,
type_to_set);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!IsNull(in, "label")) {
status =
ContactUtil::SetStrInRecord(child_record, _contacts_messenger.label,
FromJson<JsonString>(in, "label").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.messenger, child_record);
status = ContactUtil::ErrorChecker(
err, "Fail to set number value to child_record");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
record.release();
PlatformResult ImportContactAddressFromContactsRecord(
contacts_record_h contacts_record, unsigned int index,
JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
char* value = nullptr;
PlatformResult status = ContactUtil::GetStrFromRecord(
child_record, _contacts_address.country, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("country", value ? JsonValue{value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record, _contacts_address.region,
&value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("region", value ? JsonValue{value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record,
_contacts_address.locality, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("city", value ? JsonValue{value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record, _contacts_address.street,
&value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("streetAddress", value ? JsonValue{value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record,
_contacts_address.extended, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("additionalInformation",
value ? JsonValue{value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record,
_contacts_address.postal_code, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("postalCode", value ? JsonValue{value} : JsonValue{}));
status = ContactUtil::GetStrFromRecord(child_record, _contacts_address.label,
&value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("label", value ? JsonValue{value} : JsonValue{}));
bool bool_value = false;
status = ContactUtil::GetBoolFromRecord(
child_record, _contacts_address.is_default, &bool_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("isDefault", JsonValue{bool_value}));
int int_value = 0;
status = ContactUtil::GetIntFromRecord(child_record, _contacts_address.type,
&int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
JsonArray types;
if (int_value & CONTACTS_ADDRESS_TYPE_HOME) {
PlatformResult ExportContactAddressToContactsRecord(
contacts_record_h contacts_record, const JsonObject& in) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
err = contacts_record_create(_contacts_address._uri, &address_record);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Failed to create address record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&address_record, ContactsDeleter);
status = ContactUtil::SetStrInRecord(
address_record, _contacts_address.country,
FromJson<JsonString>(in, "country").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "region")) {
status =
ContactUtil::SetStrInRecord(address_record, _contacts_address.region,
FromJson<JsonString>(in, "region").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "city")) {
status =
ContactUtil::SetStrInRecord(address_record, _contacts_address.locality,
FromJson<JsonString>(in, "city").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "streetAddress")) {
status = ContactUtil::SetStrInRecord(
address_record, _contacts_address.street,
FromJson<JsonString>(in, "streetAddress").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "additionalInformation")) {
status = ContactUtil::SetStrInRecord(
address_record, _contacts_address.extended,
FromJson<JsonString>(in, "additionalInformation").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "postalCode")) {
status = ContactUtil::SetStrInRecord(
address_record, _contacts_address.postal_code,
FromJson<JsonString>(in, "postalCode").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(in, "label")) {
status =
ContactUtil::SetStrInRecord(address_record, _contacts_address.label,
FromJson<JsonString>(in, "label").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
status =
ContactUtil::SetBoolInRecord(address_record, _contacts_address.is_default,
FromJson<bool>(in, "isDefault"));
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
int type_to_set = 0;
const JsonArray& types = FromJson<JsonArray>(in, "types");
status = ContactUtil::SetIntInRecord(address_record, _contacts_address.type,
type_to_set);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.address, address_record);
status =
ContactUtil::ErrorChecker(err, "Fail to save address record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactNotesFromContactsRecord(
contacts_record_h contacts_record, unsigned int index, JsonValue* val) {
+
+ LoggerD("Enter");
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
char* note = nullptr;
PlatformResult status =
ContactUtil::GetStrFromRecord(notes_record, _contacts_note.note, ¬e);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (note) {
*val = JsonValue{note};
PlatformResult ExportNotesToContactsRecord(contacts_record_h contacts_record,
const std::string& value) {
+
+ LoggerD("Enter");
contacts_record_h notes_record = nullptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
err = contacts_record_create(_contacts_note._uri, ¬es_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Fail to create note record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(¬es_record, ContactsDeleter);
status = ContactUtil::SetStrInRecord(notes_record, _contacts_note.note,
value.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
err = contacts_record_add_child_record(contacts_record,
_contacts_contact.note, notes_record);
status =
ContactUtil::ErrorChecker(err, "Fail to save note record in database");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
PlatformResult ImportContactFromContactsRecord(
contacts_record_h contacts_record, JsonObject* out_ptr) {
+
+ LoggerD("Enter");
JsonObject& out = *out_ptr;
// contacts_record is protected by unique_ptr and its ownership is not passed
// here
if (!contacts_record) {
- LoggerW("Contacts record is null");
+ LoggerE("Contacts record is null");
return PlatformResult(ErrorCode::UNKNOWN_ERR, "Contacts record is null");
}
int id = 0;
PlatformResult status =
ContactUtil::GetIntFromRecord(contacts_record, _contacts_contact.id, &id);
- if (status.IsError()) return status;
-
+ if (status.IsError())
+ {
+ LoggerE("Fail: GetIntFromRecord");
+ return status;
+ }
out.insert(std::make_pair("id", JsonValue{std::to_string(id)}));
status = ContactUtil::GetIntFromRecord(
contacts_record, _contacts_contact.address_book_id, &id);
- if (status.IsError()) return status;
-
+ if (status.IsError())
+ {
+ LoggerE("Fail: GetIntFromRecord");
+ return status;
+ }
out.insert(std::make_pair("addressBookId", JsonValue{std::to_string(id)}));
status = ContactUtil::GetIntFromRecord(contacts_record,
_contacts_contact.person_id, &id);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("personId", JsonValue{std::to_string(id)}));
bool is_favorite = false;
status = ContactUtil::GetBoolFromRecord(
contacts_record, _contacts_contact.is_favorite, &is_favorite);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("isFavorite", JsonValue{is_favorite}));
int last_update = 0;
status = ContactUtil::GetIntFromRecord(
contacts_record, _contacts_contact.changed_time, &last_update);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("lastUpdated",
JsonValue{static_cast<double>(last_update)}));
bool is_contact_name;
status = ImportContactNameFromContactsRecord(contacts_record, &name,
&is_contact_name);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (is_contact_name) {
out.insert(std::make_pair(std::string("name"), picojson::value(name)));
int child_rec_count;
status = ContactUtil::GetNumberOfChildRecord(
contacts_record, data.property_id, &child_rec_count);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
for (unsigned int i = 0; i < child_rec_count; ++i) {
JsonValue val{JsonObject{}};
int child_rec_count;
status = ContactUtil::GetNumberOfChildRecord(
contacts_record, _contacts_contact.event, &child_rec_count);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
bool is_contact_anniv;
for (unsigned int i = 0; i < child_rec_count; ++i) {
PlatformResult status = ImportContactAnniversariesFromContactsRecord(
contacts_record, i, &anniversary.get<JsonObject>(), &is_contact_anniv);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (is_contact_anniv) {
anniversaries.push_back(anniversary);
status = ContactUtil::GetNumberOfChildRecord(
contacts_record, _contacts_contact.note, &child_rec_count);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
for (unsigned int i = 0; i < child_rec_count; ++i) {
JsonValue val{JsonObject{}};
status = ImportContactNotesFromContactsRecord(contacts_record, i, &val);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
notes.push_back(val);
}
char* value = nullptr;
status = ContactUtil::GetStrFromRecord(
contacts_record, _contacts_contact.image_thumbnail_path, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
std::make_pair("photoURI", value ? JsonValue{value} : JsonValue{});
status = ContactUtil::GetStrFromRecord(
contacts_record, _contacts_contact.ringtone_path, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
std::make_pair("ringtoneURI", value ? JsonValue{value} : JsonValue{});
value = nullptr;
status = ContactUtil::GetStrFromRecord(
contacts_record, _contacts_contact.message_alert, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair(
"messageAlertURI",
value = nullptr;
status = ContactUtil::GetStrFromRecord(contacts_record,
_contacts_contact.vibration, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair(
"vibrationURI",
if (!IsNull(in, "name")) {
PlatformResult status = ExportContactNameToContactsRecord(
contacts_record, FromJson<JsonObject>(in, "name"));
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
typedef PlatformResult (*ExportFunc)(contacts_record_h, const JsonObject&);
for (auto& data : exports) {
PlatformResult status =
ContactUtil::ClearAllContactRecord(contacts_record, data.property_id);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
const JsonArray& elements = FromJson<JsonArray>(in, data.name);
for (auto& element : elements) {
//### m_notes: ###
PlatformResult status = ContactUtil::ClearAllContactRecord(
contacts_record, _contacts_contact.note);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
const JsonArray& elements = FromJson<JsonArray>(in, "notes");
for (auto& element : elements) {
int err = contacts_record_create(_contacts_image._uri, &child_record);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Fail to create image uri record in database.");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
ContactsRecordHPtr record(&child_record, ContactsDeleter);
err = contacts_record_add_child_record(
contacts_record, _contacts_contact.image, child_record);
status = ContactUtil::ErrorChecker(err, "Fail to add child to image uri.");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
// Do not delete record, it is passed to the platform
record.release();
err = contacts_record_create(_contacts_image._uri, &child_record);
PlatformResult status = ContactUtil::ErrorChecker(
err, "Fail to create image uri record in database.");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
is_first = true;
}
ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "photoURI"));
PlatformResult status = ContactUtil::SetStrInRecord(
child_record, _contacts_image.path, real_path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (is_first) {
contacts_record, _contacts_contact.image, child_record);
PlatformResult status =
ContactUtil::ErrorChecker(err, "Fail to add child to image uri.");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// Do not delete record, it is passed to the platform
record.release();
ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "ringtoneURI"));
PlatformResult status = ContactUtil::SetStrInRecord(
contacts_record, _contacts_contact.ringtone_path, real_path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// Contact.messageAlertURI
if (!IsNull(in, "messageAlertURI")) {
FromJson<JsonString>(in, "messageAlertURI"));
PlatformResult status = ContactUtil::SetStrInRecord(
contacts_record, _contacts_contact.message_alert, real_path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// Contact.vibrationURI
ContactUtil::ConvertUriToPath(FromJson<JsonString>(in, "vibrationURI"));
PlatformResult status = ContactUtil::SetStrInRecord(
contacts_record, _contacts_contact.vibration, real_path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
return PlatformResult(ErrorCode::NO_ERROR);
int int_val = 0;
PlatformResult status = ContactUtil::GetIntFromRecord(
contacts_record, _contacts_group.id, &int_val);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("id", JsonValue{std::to_string(int_val)}));
// addressBookId
status = ContactUtil::GetIntFromRecord(
contacts_record, _contacts_group.address_book_id, &int_val);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("addressBookId", JsonValue{std::to_string(int_val)}));
char* value = nullptr;
status = ContactUtil::GetStrFromRecord(contacts_record, _contacts_group.name,
&value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("name", value ? JsonValue{value} : JsonValue{}));
value = nullptr;
status = ContactUtil::GetStrFromRecord(contacts_record,
_contacts_group.image_path, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("photoURI", value ? JsonValue{value} : JsonValue{}));
value = nullptr;
status = ContactUtil::GetStrFromRecord(contacts_record,
_contacts_group.ringtone_path, &value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("ringtoneURI", value ? JsonValue{value} : JsonValue{}));
bool bool_value = false;
status = ContactUtil::GetBoolFromRecord(
contacts_record, _contacts_group.is_read_only, &bool_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("readOnly", JsonValue{bool_value}));
PlatformResult status =
ContactUtil::SetStrInRecord(contacts_record, _contacts_group.name,
FromJson<JsonString>(in, "name").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
std::string real_path;
// photoURI
real_path = ConvertUriToPath(FromJson<JsonString>(in, "photoURI"));
PlatformResult status = ContactUtil::SetStrInRecord(
contacts_record, _contacts_group.image_path, real_path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
// ringtoneURI
if (!IsNull(in, "ringtoneURI")) {
// NOTE in the original code real path was not read
PlatformResult status = ContactUtil::SetStrInRecord(
contacts_record, _contacts_group.ringtone_path, real_path.c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
return PlatformResult(ErrorCode::NO_ERROR);
// id
PlatformResult status =
ContactUtil::GetIntFromRecord(record, _contacts_person.id, &int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(
std::make_pair("id", JsonValue(std::to_string(int_value))));
// displayName
status = ContactUtil::GetStrFromRecord(record, _contacts_person.display_name,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair(
"displayName", char_value ? JsonValue(char_value) : JsonValue{}));
// contactCount
status = ContactUtil::GetIntFromRecord(record, _contacts_person.link_count,
&int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair(
"contactCount", JsonValue(static_cast<double>(int_value))));
// hasPhoneNumber
status = ContactUtil::GetBoolFromRecord(
record, _contacts_person.has_phonenumber, &bool_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair("hasPhoneNumber", JsonValue(bool_value)));
// hasEmail
status = ContactUtil::GetBoolFromRecord(record, _contacts_person.has_email,
&bool_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair("hasEmail", JsonValue(bool_value)));
// isFavorite
status = ContactUtil::GetBoolFromRecord(record, _contacts_person.is_favorite,
&bool_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair("isFavorite", JsonValue(bool_value)));
// photoURI
status = ContactUtil::GetStrFromRecord(
record, _contacts_person.image_thumbnail_path, &char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair(
"photoURI", char_value ? JsonValue(char_value) : JsonValue{}));
// ringtoneURI
status = ContactUtil::GetStrFromRecord(record, _contacts_person.ringtone_path,
&char_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(std::make_pair(
"ringtoneURI", char_value ? JsonValue(char_value) : JsonValue{}));
// displayContactId
status = ContactUtil::GetIntFromRecord(
record, _contacts_person.display_contact_id, &int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
arguments_obj.insert(
std::make_pair("displayContactId",
PlatformResult status = ContactUtil::SetBoolInRecord(
record, _contacts_person.is_favorite, FromJson<bool>(args, "isFavorite"));
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
if (!IsNull(args, "photoURI") &&
!FromJson<JsonString>(args, "photoURI").empty()) {
PlatformResult status = ContactUtil::SetStrInRecord(
record, _contacts_person.ringtone_path,
FromJson<JsonString>(args, "ringtoneURI").c_str());
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
} else {
PlatformResult status =
ContactUtil::SetStrInRecord(record, _contacts_person.ringtone_path, "");
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
if (!IsNull(args, "displayContactId")) {
PlatformResult status = ContactUtil::SetIntInRecord(
record, _contacts_person.display_contact_id,
common::stol(FromJson<JsonString>(args, "displayContactId")));
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
}
return PlatformResult(ErrorCode::NO_ERROR);
int int_value = -1;
PlatformResult status = ContactUtil::GetIntFromRecord(
*contacts_record_ptr, _contacts_contact.person_id, &int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("personId", JsonValue{std::to_string(int_value)}));
status = ContactUtil::GetIntFromRecord(
*contacts_record_ptr, _contacts_contact.address_book_id, &int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("addressBookId", JsonValue{std::to_string(int_value)}));
status = ContactUtil::GetIntFromRecord(
*contacts_record_ptr, _contacts_contact.changed_time, &int_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(
std::make_pair("lastUpdated", JsonValue{static_cast<double>(int_value)}));
bool bool_value = false;
status = ContactUtil::GetBoolFromRecord(
*contacts_record_ptr, _contacts_contact.is_favorite, &bool_value);
- if (status.IsError()) return status;
+ if (status.IsError()) {
+ LoggerE("Error: %s", status.message().c_str());
+ return status;
+ }
out.insert(std::make_pair("isFavorite", JsonValue{bool_value}));