namespace AddressBook {
using namespace common;
-//using namespace wrt::common;
typedef std::shared_ptr<JsonValue> shared_json_value;
} // anonymous namespace
-void AddressBook_get(const JsonObject& args, JsonObject& out) {
+void AddressBookGet(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
int contact_id = common::stol(FromJson<JsonString>(args, "id"));
&contacts_record, ContactUtil::ContactsDeleter);
out.insert(std::make_pair("id", std::to_string(contact_id)));
- ContactUtil::ImportContactFromContactsRecord(*contacts_record_ptr,
- &out);
+ ContactUtil::ImportContactFromContactsRecord(*contacts_record_ptr, &out);
ContactUtil::UpdateAdditionalInformation(contacts_record_ptr, &out);
}
-void AddressBook_add(const JsonObject& args, JsonObject& out) {
+void AddressBookAdd(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
const JsonObject& contact = FromJson<JsonObject>(args, "contact");
ContactUtil::UpdateAdditionalInformation(contacts_record_ptr, &out);
}
-void AddressBook_update(const JsonObject& args, JsonObject& out) {
+void AddressBookUpdate(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
const JsonObject& contact = FromJson<JsonObject>(args, "contact");
if (CONTACTS_ERROR_NONE != err) {
if (CONTACTS_ERROR_INVALID_PARAMETER == err) {
LoggerE("Error during executing contacts_db_update_record(). Error: %d",
- err);
+ err);
throw common::NotFoundException(
"Error during executing contacts_db_update_record().");
}
if (CONTACTS_ERROR_DB == err) {
LoggerE("Error during executing contacts_db_update_record(). Error: %d",
- err);
+ err);
throw common::UnknownException(
"Error during executing contacts_db_update_record().");
}
ContactUtil::UpdateAdditionalInformation(contacts_record_ptr, &out);
}
-void AddressBook_remove(const JsonObject& args, JsonObject&) {
+void AddressBookRemove(const JsonObject& args, JsonObject&) {
LoggerE("entered");
ContactUtil::CheckDBConnection();
}
}
-void AddressBook_addBatch(const JsonObject& args, JsonArray& out) {
+void AddressBookAddBatch(const JsonObject& args, JsonArray& out) {
LoggerD("Enter");
ContactUtil::CheckDBConnection();
const JsonArray& batch_args = FromJson<JsonArray>(args, "batchArgs");
- long addressBookId = common::stol(FromJson<JsonString>(args, "addressBookId"));
+ long addressBookId =
+ common::stol(FromJson<JsonString>(args, "addressBookId"));
addressBookId = addressBookId == -1 ? 0 : addressBookId;
unsigned length = batch_args.size();
LoggerE("list creation failed, code: %d", error_code);
throw new common::UnknownException("list creation failed");
}
- ContactUtil::ContactsListHPtr contacts_list_ptr(&contacts_list, ContactUtil::ContactsListDeleter);
+ ContactUtil::ContactsListHPtr contacts_list_ptr(
+ &contacts_list, ContactUtil::ContactsListDeleter);
for (auto& item : batch_args) {
contacts_record_h contacts_record = nullptr;
LoggerW("Contacts record create error, error code: %d", err);
throw common::UnknownException("Contacts record create error");
}
- ContactUtil::ContactsRecordHPtr x(&contacts_record, ContactUtil::ContactsDeleter);
- ContactUtil::ExportContactToContactsRecord(contacts_record, JsonCast<JsonObject>(item));
- ContactUtil::SetIntInRecord(contacts_record, _contacts_contact.address_book_id, addressBookId);
+ ContactUtil::ContactsRecordHPtr x(&contacts_record,
+ ContactUtil::ContactsDeleter);
+ ContactUtil::ExportContactToContactsRecord(contacts_record,
+ JsonCast<JsonObject>(item));
+ ContactUtil::SetIntInRecord(
+ contacts_record, _contacts_contact.address_book_id, addressBookId);
error_code = contacts_list_add(*contacts_list_ptr, *(x.release()));
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("error during add record to list, code: %d", error_code);
for (unsigned int i = 0; i < count; i++) {
JsonObject out_object;
contacts_record_h contact_record = nullptr;
- error_code = contacts_db_get_record(_contacts_contact._uri, ids[i], &contact_record);
+ error_code =
+ contacts_db_get_record(_contacts_contact._uri, ids[i], &contact_record);
if (CONTACTS_ERROR_NONE != error_code) {
if (ids) {
free(ids);
}
// TODO all batch operations should be implemented using CAPI batch functions
-void AddressBook_batchFunc(NativeFunction impl, const char *single_arg_name,
- const JsonObject &args, JsonArray &out) {
- const JsonArray &batch_args = FromJson<JsonArray>(args, "batchArgs");
- const JsonObject &address_book = FromJson<JsonObject>(args, "addressBook");
+void AddressBookBatchFunc(NativeFunction impl, const char* single_arg_name,
+ const JsonObject& args, JsonArray& out) {
+ const JsonArray& batch_args = FromJson<JsonArray>(args, "batchArgs");
+ const JsonObject& address_book = FromJson<JsonObject>(args, "addressBook");
int i = 0;
- for (auto &item : batch_args) {
+ for (auto& item : batch_args) {
++i;
JsonObject single_args{};
}
}
-void AddressBook_find(const JsonObject& args, JsonArray& array) {
+void AddressBookFind(const JsonObject& args, JsonArray& array) {
ContactUtil::CheckDBConnection();
// TODO implement contact filter and sorting.
error_code = contacts_query_create(_contacts_contact._uri, &query);
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_create");
- ContactUtil::ContactsQueryHPtr query_ptr(&query, ContactUtil::ContactsQueryDeleter);
+ ContactUtil::ContactsQueryHPtr query_ptr(&query,
+ ContactUtil::ContactsQueryDeleter);
error_code = contacts_filter_create(_contacts_contact._uri, &filter);
ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_create");
- ContactUtil::ContactsFilterPtr filter_ptr(filter, ContactUtil::ContactsFilterDeleter);
- error_code = contacts_filter_add_int(filter, _contacts_contact.address_book_id,
- CONTACTS_MATCH_EQUAL, addressbook_id);
+ ContactUtil::ContactsFilterPtr filter_ptr(filter,
+ ContactUtil::ContactsFilterDeleter);
+ error_code =
+ contacts_filter_add_int(filter, _contacts_contact.address_book_id,
+ CONTACTS_MATCH_EQUAL, addressbook_id);
ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_int");
error_code = contacts_query_set_filter(query, filter);
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
error_code = contacts_db_get_records_with_query(query, 0, 0, &list);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_db_get_records_with_query");
- ContactUtil::ContactsListHPtr list_ptr(&list, ContactUtil::ContactsListDeleter);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_db_get_records_with_query");
+ ContactUtil::ContactsListHPtr list_ptr(&list,
+ ContactUtil::ContactsListDeleter);
int record_count = 0;
error_code = contacts_list_get_count(list, &record_count);
for (unsigned int i = 0; i < record_count; i++) {
contacts_record_h record;
error_code = contacts_list_get_current_record_p(list, &record);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_list_get_current_record_p");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_list_get_current_record_p");
int id_value = 0;
- error_code = contacts_record_get_int(record, _contacts_contact.id, &id_value);
+ error_code =
+ contacts_record_get_int(record, _contacts_contact.id, &id_value);
ContactUtil::ErrorChecker(error_code, "Failed contacts_record_get_int");
array.push_back(JsonValue(static_cast<double>(id_value)));
}
}
-void AddressBook_addGroup(const JsonObject& args, JsonObject& out) {
+void AddressBookAddGroup(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
const JsonObject& group = FromJson<JsonObject>(args, "group");
if (!IsNull(group, "id") || !IsNull(group, "addressBookId")) {
int err = CONTACTS_ERROR_NONE;
contacts_record_h contacts_record = nullptr;
err = contacts_record_create(_contacts_group._uri, &contacts_record);
- ContactUtil::ErrorChecker(err, "Error during executing contacts_record_create()");
+ ContactUtil::ErrorChecker(err,
+ "Error during executing contacts_record_create()");
- ContactUtil::ContactsRecordHPtr record(&contacts_record, ContactUtil::ContactsDeleter);
+ ContactUtil::ContactsRecordHPtr record(&contacts_record,
+ ContactUtil::ContactsDeleter);
- long addressbook_id = common::stol(FromJson<JsonString>(args, "addressBookId"));
+ long addressbook_id =
+ common::stol(FromJson<JsonString>(args, "addressBookId"));
addressbook_id = (IsUnified(addressbook_id)) ? 0 : addressbook_id;
- ContactUtil::SetIntInRecord(contacts_record, _contacts_group.address_book_id, addressbook_id);
+ ContactUtil::SetIntInRecord(contacts_record, _contacts_group.address_book_id,
+ addressbook_id);
ContactUtil::ExportContactGroupToContactsRecord(contacts_record, group);
int groupId = 0;
out.insert(std::make_pair("addressBookId", std::to_string(addressbook_id)));
}
-void AddressBook_getGroup(const JsonObject& args, JsonObject& out) {
+void AddressBookGetGroup(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
long id = common::stol(FromJson<JsonString>(args, "id"));
throw common::NotFoundException("Group not exist");
}
- ContactUtil::ContactsRecordHPtr record(&contacts_record, ContactUtil::ContactsDeleter);
+ ContactUtil::ContactsRecordHPtr record(&contacts_record,
+ ContactUtil::ContactsDeleter);
- long addressbook_id = common::stol(FromJson<JsonString>(args, "addressBook", "id"));
+ long addressbook_id =
+ common::stol(FromJson<JsonString>(args, "addressBook", "id"));
if (IsUnified(addressbook_id)) {
int address_book_id = 0;
ContactUtil::GetIntFromRecord(
ContactUtil::ImportContactGroupFromContactsRecord(contacts_record, &out);
}
-void AddressBook_updateGroup(const JsonObject& args, JsonObject&) {
+void AddressBookUpdateGroup(const JsonObject& args, JsonObject&) {
ContactUtil::CheckDBConnection();
const JsonObject& group = FromJson<JsonObject>(args, "group");
throw common::InvalidValuesException("Group object is not added");
}
- long addressbook_id = common::stol(FromJson<JsonString>(args, "addressBookId"));
- long group_addressbook_id = common::stol(FromJson<JsonString>(group, "addressBookId"));
+ long addressbook_id =
+ common::stol(FromJson<JsonString>(args, "addressBookId"));
+ long group_addressbook_id =
+ common::stol(FromJson<JsonString>(group, "addressBookId"));
if (IsUnified(addressbook_id) && (addressbook_id != group_addressbook_id)) {
LoggerE("Wrong address book");
throw common::InvalidValuesException("Wrong address book");
}
contacts_record_h contacts_record = nullptr;
- int err = contacts_db_get_record(_contacts_group._uri, group_id, &contacts_record);
+ int err =
+ contacts_db_get_record(_contacts_group._uri, group_id, &contacts_record);
if (CONTACTS_ERROR_NONE != err || nullptr == contacts_record) {
LoggerE("Group not exist");
throw common::NotFoundException("Group not exist");
ContactUtil::ErrorChecker(err, "Problem during db_update_record");
}
-void AddressBook_removeGroup(const JsonObject& args, JsonObject&) {
+void AddressBookRemoveGroup(const JsonObject& args, JsonObject&) {
ContactUtil::CheckDBConnection();
long id = common::stol(FromJson<JsonString>(args, "id"));
&group_addressbook_id);
if (group_addressbook_id != addressbook_id) {
- throw common::UnknownException("Contact is not a member of this address book");
+ throw common::UnknownException(
+ "Contact is not a member of this address book");
}
}
ContactUtil::ErrorChecker(err, "Problem during db_delete_record");
}
-void AddressBook_getGroups(const JsonObject& args, JsonArray& out) {
+void AddressBookGetGroups(const JsonObject& args, JsonArray& out) {
ContactUtil::CheckDBConnection();
int err = CONTACTS_ERROR_NONE;
}
JsonValue group{JsonObject{}};
- ContactUtil::ImportContactGroupFromContactsRecord(contacts_record, &group.get<JsonObject>());
+ ContactUtil::ImportContactGroupFromContactsRecord(contacts_record,
+ &group.get<JsonObject>());
out.push_back(group);
if (i < record_count - 1) {
}
namespace {
-void AddressBook_listenerCallback(const char* view_uri, void* user_data) {
+void AddressBookListenerCallback(const char* view_uri, void* user_data) {
LoggerD("entered");
(void)view_uri;
(void)user_data;
LoggerW("get current version returns error, code: %d", error_code);
}
- for (int version = ContactInstance::current_state; version < current_version; ++version) {
+ for (int version = ContactInstance::current_state; version < current_version;
+ ++version) {
int latest_version = 0;
error_code = contacts_db_get_changes_by_version(
- _contacts_contact_updated_info._uri, kUnifiedAddressBookId,
- version, &contacts_list, &latest_version);
+ _contacts_contact_updated_info._uri, kUnifiedAddressBookId, version,
+ &contacts_list, &latest_version);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("cannot get changes by version, code: %d", error_code);
continue;
JsonObject& result_obj = result.get<JsonObject>();
result_obj.insert(std::make_pair("listenerId", kContactListenerId));
JsonArray& added = result_obj.insert(std::make_pair("added", JsonArray{}))
- .first->second.get<JsonArray>();
- JsonArray& updated = result_obj.insert(std::make_pair("updated", JsonArray{}))
- .first->second.get<JsonArray>();
- JsonArray& removed = result_obj.insert(std::make_pair("removed", JsonArray{}))
- .first->second.get<JsonArray>();
+ .first->second.get<JsonArray>();
+ JsonArray& updated =
+ result_obj.insert(std::make_pair("updated", JsonArray{}))
+ .first->second.get<JsonArray>();
+ JsonArray& removed =
+ result_obj.insert(std::make_pair("removed", JsonArray{}))
+ .first->second.get<JsonArray>();
for (unsigned int i = 0; i < count; i++) {
contacts_record_h contact_updated_record = nullptr;
error_code = contacts_list_get_current_record_p(contacts_list,
- &contact_updated_record);
+ &contact_updated_record);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerW("fail to get contact from list, code: %d", error_code);
break;
try {
ContactUtil::GetIntFromRecord(contact_updated_record,
- _contacts_contact_updated_info.contact_id, &changed_id);
+ _contacts_contact_updated_info.contact_id,
+ &changed_id);
- ContactUtil::GetIntFromRecord(contact_updated_record,
+ ContactUtil::GetIntFromRecord(
+ contact_updated_record,
_contacts_contact_updated_info.address_book_id, &changed_ab_id);
ContactUtil::GetIntFromRecord(contact_updated_record,
- _contacts_contact_updated_info.type, &changed_type);
- } catch (const PlatformException &) {
+ _contacts_contact_updated_info.type,
+ &changed_type);
+ }
+ catch (const PlatformException&) {
LoggerE("fail to get int from record");
break;
}
contacts_record_h contacts_record = nullptr;
error_code = contacts_db_get_record(_contacts_contact._uri, changed_id,
- &contacts_record);
+ &contacts_record);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerW("fail to get contact from record");
&contacts_record, ContactUtil::ContactsDeleter);
JsonValue contact{JsonObject{}};
- ContactUtil::ImportContactFromContactsRecord(contacts_record,
- &contact.get<JsonObject>());
+ ContactUtil::ImportContactFromContactsRecord(
+ contacts_record, &contact.get<JsonObject>());
if (CONTACTS_CHANGE_INSERTED == changed_type) {
added.push_back(std::move(contact));
}
}
-void AddressBook_startListening(const JsonObject&, JsonObject& out) {
+void AddressBookStartListening(const JsonObject&, JsonObject& out) {
ContactUtil::CheckDBConnection();
// Set the initial latest version before registering the callback.
// The callback should only be registered once so no race can occur.
- int error_code = contacts_db_get_current_version(&ContactInstance::current_state);
+ int error_code =
+ contacts_db_get_current_version(&ContactInstance::current_state);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerW("get current version returns error, code: %d", error_code);
}
- error_code = contacts_db_add_changed_cb(
- _contacts_contact._uri, AddressBook_listenerCallback, NULL);
+ error_code = contacts_db_add_changed_cb(_contacts_contact._uri,
+ AddressBookListenerCallback, NULL);
if (CONTACTS_ERROR_NONE != error_code) {
- LoggerE("Error while registering listener to contacts db, code: %d", error_code);
+ LoggerE("Error while registering listener to contacts db, code: %d",
+ error_code);
throw UnknownException("Error while registering listener to contacts db");
}
}
-void AddressBook_stopListening(const JsonObject&, JsonObject& out) {
+void AddressBookStopListening(const JsonObject&, JsonObject& out) {
ContactUtil::CheckDBConnection();
int error_code = contacts_db_remove_changed_cb(
- _contacts_contact._uri, AddressBook_listenerCallback, NULL);
+ _contacts_contact._uri, AddressBookListenerCallback, NULL);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("Error while removing listener");
typedef std::function<void(const JsonObject&, JsonObject&)> NativeFunction;
-void AddressBook_get(const JsonObject& args, JsonObject& out);
-void AddressBook_add(const JsonObject& args, JsonObject& out);
-void AddressBook_update(const JsonObject& args, JsonObject& out);
-void AddressBook_remove(const JsonObject& args, JsonObject&);
-void AddressBook_find(const JsonObject& args, JsonArray& array);
-void AddressBook_addGroup(const JsonObject& args, JsonObject& out);
-void AddressBook_getGroup(const JsonObject& args, JsonObject& out);
-void AddressBook_updateGroup(const JsonObject& args, JsonObject&);
-void AddressBook_removeGroup(const JsonObject& args, JsonObject&);
-void AddressBook_getGroups(const JsonObject& args, JsonArray& out);
-void AddressBook_startListening(const JsonObject& args, JsonObject& out);
-void AddressBook_stopListening(const JsonObject& args, JsonObject& out);
-
-void AddressBook_batchFunc(NativeFunction impl, const char *single_arg_name,
- const JsonObject &args, JsonArray &out);
+void AddressBookGet(const JsonObject& args, JsonObject& out);
+void AddressBookAdd(const JsonObject& args, JsonObject& out);
+void AddressBookUpdate(const JsonObject& args, JsonObject& out);
+void AddressBookRemove(const JsonObject& args, JsonObject&);
+void AddressBookFind(const JsonObject& args, JsonArray& array);
+void AddressBookAddGroup(const JsonObject& args, JsonObject& out);
+void AddressBookGetGroup(const JsonObject& args, JsonObject& out);
+void AddressBookUpdateGroup(const JsonObject& args, JsonObject&);
+void AddressBookRemoveGroup(const JsonObject& args, JsonObject&);
+void AddressBookGetGroups(const JsonObject& args, JsonArray& out);
+void AddressBookStartListening(const JsonObject& args, JsonObject& out);
+void AddressBookStopListening(const JsonObject& args, JsonObject& out);
+
+void AddressBookBatchFunc(NativeFunction impl, const char* single_arg_name,
+ const JsonObject& args, JsonArray& out);
// TODO all batch operations should be implemented using CAPI batch functions
-void AddressBook_addBatch(const JsonObject& args, JsonArray& out);
+void AddressBookAddBatch(const JsonObject& args, JsonArray& out);
} // AddressBook
} // contact
using namespace common;
ContactInstance& ContactInstance::GetInstance() {
- static ContactInstance instance;
- return instance;
+ static ContactInstance instance;
+ return instance;
}
int ContactInstance::current_state = 0;
RegisterHandler(c, std::bind(&ContactInstance::x, this, _1, _2));
// Contact Manager
- REGISTER_ASYNC("ContactManager_getAddressBooks", ContactManager_getAddressBooks);
- REGISTER_SYNC("ContactManager_getAddressBook", ContactManager_getAddressBook);
- REGISTER_SYNC("ContactManager_addAddressBook", ContactManager_addAddressBook);
- REGISTER_SYNC("ContactManager_removeAddressBook", ContactManager_removeAddressBook);
- REGISTER_SYNC("ContactManager_get", ContactManager_get);
- REGISTER_SYNC("ContactManager_update", ContactManager_update);
- REGISTER_ASYNC("ContactManager_updateBatch", ContactManager_updateBatch);
- REGISTER_SYNC("ContactManager_remove", ContactManager_remove);
- REGISTER_ASYNC("ContactManager_removeBatch", ContactManager_removeBatch);
- REGISTER_ASYNC("ContactManager_find", ContactManager_find);
- REGISTER_SYNC("ContactManager_importFromVCard", ContactManager_importFromVCard);
- REGISTER_SYNC("ContactManager_startListening", ContactManager_startListening);
- REGISTER_SYNC("ContactManager_stopListening", ContactManager_stopListening);
+ REGISTER_ASYNC("ContactManager_getAddressBooks",
+ ContactManagerGetAddressBooks);
+ REGISTER_SYNC("ContactManager_getAddressBook", ContactManagerGetAddressBook);
+ REGISTER_SYNC("ContactManager_addAddressBook", ContactManagerAddAddressBook);
+ REGISTER_SYNC("ContactManager_removeAddressBook",
+ ContactManagerRemoveAddressBook);
+ REGISTER_SYNC("ContactManager_get", ContactManagerGet);
+ REGISTER_SYNC("ContactManager_update", ContactManagerUpdate);
+ REGISTER_ASYNC("ContactManager_updateBatch", ContactManagerUpdateBatch);
+ REGISTER_SYNC("ContactManager_remove", ContactManagerRemove);
+ REGISTER_ASYNC("ContactManager_removeBatch", ContactManagerRemoveBatch);
+ REGISTER_ASYNC("ContactManager_find", ContactManagerFind);
+ REGISTER_SYNC("ContactManager_importFromVCard",
+ ContactManagerImportFromVCard);
+ REGISTER_SYNC("ContactManager_startListening", ContactManagerStartListening);
+ REGISTER_SYNC("ContactManager_stopListening", ContactManagerStopListening);
// AddressBook
- REGISTER_ASYNC("AddressBook_addBatch", AddressBook_addBatch);
- REGISTER_ASYNC("AddressBook_updateBatch", AddressBook_updateBatch);
- REGISTER_ASYNC("AddressBook_removeBatch", AddressBook_removeBatch);
- REGISTER_SYNC("AddressBook_get", AddressBook_get);
- REGISTER_SYNC("AddressBook_add", AddressBook_add);
- REGISTER_SYNC("AddressBook_update", AddressBook_update);
- REGISTER_SYNC("AddressBook_remove", AddressBook_remove);
- REGISTER_ASYNC("AddressBook_find", AddressBook_find);
- REGISTER_SYNC("AddressBook_addGroup", AddressBook_addGroup);
- REGISTER_SYNC("AddressBook_getGroup", AddressBook_getGroup);
- REGISTER_SYNC("AddressBook_updateGroup", AddressBook_updateGroup);
- REGISTER_SYNC("AddressBook_removeGroup", AddressBook_removeGroup);
- REGISTER_SYNC("AddressBook_getGroups", AddressBook_getGroups);
- REGISTER_SYNC("AddressBook_startListening", AddressBook_startListening);
- REGISTER_SYNC("AddressBook_stopListening", AddressBook_stopListening);
+ REGISTER_ASYNC("AddressBook_addBatch", AddressBookAddBatch);
+ REGISTER_ASYNC("AddressBook_updateBatch", AddressBookUpdateBatch);
+ REGISTER_ASYNC("AddressBook_removeBatch", AddressBookRemoveBatch);
+ REGISTER_SYNC("AddressBook_get", AddressBookGet);
+ REGISTER_SYNC("AddressBook_add", AddressBookAdd);
+ REGISTER_SYNC("AddressBook_update", AddressBookUpdate);
+ REGISTER_SYNC("AddressBook_remove", AddressBookRemove);
+ REGISTER_ASYNC("AddressBook_find", AddressBookFind);
+ REGISTER_SYNC("AddressBook_addGroup", AddressBookAddGroup);
+ REGISTER_SYNC("AddressBook_getGroup", AddressBookGetGroup);
+ REGISTER_SYNC("AddressBook_updateGroup", AddressBookUpdateGroup);
+ REGISTER_SYNC("AddressBook_removeGroup", AddressBookRemoveGroup);
+ REGISTER_SYNC("AddressBook_getGroups", AddressBookGetGroups);
+ REGISTER_SYNC("AddressBook_startListening", AddressBookStartListening);
+ REGISTER_SYNC("AddressBook_stopListening", AddressBookStopListening);
// Person
- REGISTER_SYNC("Person_link", Person_link);
- REGISTER_SYNC("Person_unlink", Person_unlink);
+ REGISTER_SYNC("Person_link", PersonLink);
+ REGISTER_SYNC("Person_unlink", PersonUnlink);
#undef REGISTER_SYNC
#undef REGISTER_ASYNC
ContactInstance::~ContactInstance() {}
-void ContactInstance::AddressBook_get(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookGet(const JsonValue& args, JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_get(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookGet(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_add(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookAdd(const JsonValue& args, JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_add(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookAdd(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_addBatch(const JsonValue &args, JsonObject &out) {
+void ContactInstance::AddressBookAddBatch(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
// TODO check privileges
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr <JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- AddressBook::AddressBook_addBatch(common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ AddressBook::AddressBookAddBatch(common::JsonCast<JsonObject>(args),
+ result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
- } catch (const PlatformException &e) {
+ }
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr <JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::AddressBook_removeBatch(const JsonValue &args, JsonObject &out) {
+void ContactInstance::AddressBookRemoveBatch(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
// TODO check privileges
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr<JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- // TODO all batch operations should be implemented using CAPI batch functions
- AddressBook::AddressBook_batchFunc(AddressBook::AddressBook_remove, "id",
- common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ // TODO all batch operations should be implemented using CAPI batch
+ // functions
+ AddressBook::AddressBookBatchFunc(AddressBook::AddressBookRemove, "id",
+ common::JsonCast<JsonObject>(args),
+ result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
}
- catch (const PlatformException &e) {
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr<JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::AddressBook_updateBatch(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookUpdateBatch(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
// TODO check privileges
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr<JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- // TODO all batch operations should be implemented using CAPI batch functions
- AddressBook::AddressBook_batchFunc(AddressBook::AddressBook_update, "contact",
- common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ // TODO all batch operations should be implemented using CAPI batch
+ // functions
+ AddressBook::AddressBookBatchFunc(
+ AddressBook::AddressBookUpdate, "contact",
+ common::JsonCast<JsonObject>(args), result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
}
- catch (const PlatformException &e) {
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr<JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::AddressBook_update(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::AddressBookUpdate(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_update(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookUpdate(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_remove(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::AddressBookRemove(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_remove(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookRemove(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(out);
}
-void ContactInstance::AddressBook_find(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookFind(const JsonValue& args, JsonObject& out) {
LoggerD("entered");
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr<JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- AddressBook::AddressBook_find(JsonCast<JsonObject>(args), result.get<JsonArray>());
+ AddressBook::AddressBookFind(JsonCast<JsonObject>(args),
+ result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
- } catch (const PlatformException &e) {
+ }
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr<JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::AddressBook_addGroup(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::AddressBookAddGroup(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_addGroup(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookAddGroup(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_getGroup(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::AddressBookGetGroup(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_getGroup(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookGetGroup(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_updateGroup(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::AddressBookUpdateGroup(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_updateGroup(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookUpdateGroup(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(out);
}
-void ContactInstance::AddressBook_removeGroup(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::AddressBookRemoveGroup(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_removeGroup(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookRemoveGroup(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(out);
}
-void ContactInstance::AddressBook_getGroups(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookGetGroups(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonArray{}};
- AddressBook::AddressBook_getGroups(common::JsonCast<JsonObject>(args),
- val.get<JsonArray>());
+ AddressBook::AddressBookGetGroups(common::JsonCast<JsonObject>(args),
+ val.get<JsonArray>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_getAddressBooks(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerGetAddressBooks(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
// TODO check privileges
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr<JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- ContactManager::ContactManager_getAddressBooks(common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ ContactManager::ContactManagerGetAddressBooks(
+ common::JsonCast<JsonObject>(args), result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
- } catch (const PlatformException &e) {
+ }
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr<JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::ContactManager_getAddressBook(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerGetAddressBook(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_getAddressBook(
+ ContactManager::ContactManagerGetAddressBook(
common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_addAddressBook(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerAddAddressBook(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_addAddressBook(
+ ContactManager::ContactManagerAddAddressBook(
common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_removeAddressBook(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerRemoveAddressBook(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_removeAddressBook(
+ ContactManager::ContactManagerRemoveAddressBook(
common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_startListening(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookStartListening(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_startListening(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookStartListening(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::AddressBook_stopListening(const JsonValue& args, JsonObject& out) {
+void ContactInstance::AddressBookStopListening(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- AddressBook::AddressBook_stopListening(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ AddressBook::AddressBookStopListening(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_get(const JsonValue& args,
- JsonObject& out) {
+void ContactInstance::ContactManagerGet(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_get(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ ContactManager::ContactManagerGet(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_update(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerUpdate(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_update(common::JsonCast<JsonObject>(args), val.get<JsonObject>());
+ ContactManager::ContactManagerUpdate(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(out);
}
-void ContactInstance::ContactManager_updateBatch(const JsonValue &args, JsonObject &out) {
+void ContactInstance::ContactManagerUpdateBatch(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
// TODO check privileges
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr<JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- // TODO all batch operations should be implemented using CAPI batch functions
- AddressBook::AddressBook_batchFunc(ContactManager::ContactManager_update, "person",
- common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ // TODO all batch operations should be implemented using CAPI batch
+ // functions
+ AddressBook::AddressBookBatchFunc(
+ ContactManager::ContactManagerUpdate, "person",
+ common::JsonCast<JsonObject>(args), result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
}
- catch (const PlatformException &e) {
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr<JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::ContactManager_remove(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerRemove(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_remove(common::JsonCast<JsonObject>(args), val.get<JsonObject>());
+ ContactManager::ContactManagerRemove(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(out);
}
-void ContactInstance::ContactManager_removeBatch(const JsonValue &args, JsonObject &out) {
+void ContactInstance::ContactManagerRemoveBatch(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
// TODO check privileges
const double callback_id = args.get("callbackId").get<double>();
- auto get = [=](const std::shared_ptr<JsonValue> &response) -> void {
+ auto get = [=](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- // TODO all batch operations should be implemented using CAPI batch functions
- AddressBook::AddressBook_batchFunc(ContactManager::ContactManager_remove, "personId",
- common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ // TODO all batch operations should be implemented using CAPI batch
+ // functions
+ AddressBook::AddressBookBatchFunc(
+ ContactManager::ContactManagerRemove, "personId",
+ common::JsonCast<JsonObject>(args), result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
}
- catch (const PlatformException &e) {
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr<JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::ContactManager_find(const JsonValue &args, JsonObject &out) {
+void ContactInstance::ContactManagerFind(const JsonValue& args,
+ JsonObject& out) {
LoggerD("entered");
const double callback_id = args.get("callbackId").get<double>();
- auto get = [this, args](const std::shared_ptr <JsonValue> &response) -> void {
+ auto get = [ this, args ](const std::shared_ptr<JsonValue> & response)->void {
try {
JsonValue result = JsonValue(JsonArray());
- ContactManager::ContactManager_find(common::JsonCast<JsonObject>(args),
- result.get<JsonArray>());
+ ContactManager::ContactManagerFind(common::JsonCast<JsonObject>(args),
+ result.get<JsonArray>());
ReportSuccess(result, response->get<JsonObject>());
- } catch (const PlatformException &e) {
+ }
+ catch (const PlatformException& e) {
ReportError(e, response->get<JsonObject>());
}
};
- auto get_response = [this, callback_id](const std::shared_ptr <JsonValue> &response) {
- JsonObject &obj = response->get<JsonObject>();
+ auto get_response = [this, callback_id](
+ const std::shared_ptr<JsonValue>& response) {
+ JsonObject& obj = response->get<JsonObject>();
obj.insert(std::make_pair("callbackId", callback_id));
PostMessage(response->serialize().c_str());
};
- TaskQueue::GetInstance().Queue<JsonValue>(get, get_response,
+ TaskQueue::GetInstance().Queue<JsonValue>(
+ get, get_response,
std::shared_ptr<JsonValue>(new JsonValue(JsonObject())));
}
-void ContactInstance::ContactManager_importFromVCard(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerImportFromVCard(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_importFromVCard(
+ ContactManager::ContactManagerImportFromVCard(
common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_startListening(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerStartListening(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_startListening(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ ContactManager::ContactManagerStartListening(
+ common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::ContactManager_stopListening(const JsonValue& args, JsonObject& out) {
+void ContactInstance::ContactManagerStopListening(const JsonValue& args,
+ JsonObject& out) {
JsonValue val{JsonObject{}};
- ContactManager::ContactManager_stopListening(common::JsonCast<JsonObject>(args),
- val.get<JsonObject>());
+ ContactManager::ContactManagerStopListening(
+ common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(val, out);
}
-void ContactInstance::Person_link(const JsonValue& args, JsonObject& out) {
+void ContactInstance::PersonLink(const JsonValue& args, JsonObject& out) {
JsonValue val{JsonObject{}};
- Person::Person_link(common::JsonCast<JsonObject>(args), val.get<JsonObject>());
+ Person::PersonLink(common::JsonCast<JsonObject>(args), val.get<JsonObject>());
ReportSuccess(out);
}
-void ContactInstance::Person_unlink(const JsonValue& args, JsonObject& out) {
+void ContactInstance::PersonUnlink(const JsonValue& args, JsonObject& out) {
JsonValue val{JsonObject{}};
- Person::Person_unlink(common::JsonCast<JsonObject>(args), val.get<JsonObject>());
+ Person::PersonUnlink(common::JsonCast<JsonObject>(args),
+ val.get<JsonObject>());
ReportSuccess(val, out);
}
virtual ~ContactInstance();
private:
- void AddressBook_get(const JsonValue& args, JsonObject& out);
- void AddressBook_add(const JsonValue& args, JsonObject& out);
- void AddressBook_addBatch(const JsonValue& args, JsonObject& out);
- void AddressBook_update(const JsonValue& args, JsonObject& out);
- void AddressBook_updateBatch(const JsonValue& args, JsonObject& out);
- void AddressBook_remove(const JsonValue& args, JsonObject& out);
- void AddressBook_removeBatch(const JsonValue& args, JsonObject& out);
- void AddressBook_find(const JsonValue& args, JsonObject& out);
-
- void AddressBook_getGroup(const JsonValue& args, JsonObject& out);
- void AddressBook_getGroups(const JsonValue& args, JsonObject& out);
- void AddressBook_addGroup(const JsonValue& args, JsonObject& out);
- void AddressBook_updateGroup(const JsonValue& args, JsonObject& out);
- void AddressBook_removeGroup(const JsonValue& args, JsonObject& out);
-
- void AddressBook_startListening(const JsonValue& args, JsonObject& out);
- void AddressBook_stopListening(const JsonValue& args,JsonObject& out);
+ void AddressBookGet(const JsonValue& args, JsonObject& out);
+ void AddressBookAdd(const JsonValue& args, JsonObject& out);
+ void AddressBookAddBatch(const JsonValue& args, JsonObject& out);
+ void AddressBookUpdate(const JsonValue& args, JsonObject& out);
+ void AddressBookUpdateBatch(const JsonValue& args, JsonObject& out);
+ void AddressBookRemove(const JsonValue& args, JsonObject& out);
+ void AddressBookRemoveBatch(const JsonValue& args, JsonObject& out);
+ void AddressBookFind(const JsonValue& args, JsonObject& out);
+
+ void AddressBookGetGroup(const JsonValue& args, JsonObject& out);
+ void AddressBookGetGroups(const JsonValue& args, JsonObject& out);
+ void AddressBookAddGroup(const JsonValue& args, JsonObject& out);
+ void AddressBookUpdateGroup(const JsonValue& args, JsonObject& out);
+ void AddressBookRemoveGroup(const JsonValue& args, JsonObject& out);
+
+ void AddressBookStartListening(const JsonValue& args, JsonObject& out);
+ void AddressBookStopListening(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void getAddressBooks(successCallback, errorCallback);
* {status: 'success', result: {addressbooks}}
* @endcode
*/
- void ContactManager_getAddressBooks(const JsonValue& args, JsonObject& out);
+ void ContactManagerGetAddressBooks(const JsonValue& args, JsonObject& out);
/**
* Signature: @code AddressBook getAddressBook(addressBookId); @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_getAddressBook(const JsonValue& args, JsonObject& out);
+ void ContactManagerGetAddressBook(const JsonValue& args, JsonObject& out);
- void ContactManager_addAddressBook(const JsonValue& args, JsonObject& out);
- void ContactManager_removeAddressBook(const JsonValue& args, JsonObject& out);
+ void ContactManagerAddAddressBook(const JsonValue& args, JsonObject& out);
+ void ContactManagerRemoveAddressBook(const JsonValue& args, JsonObject& out);
/**
* Signature: @code Person get(personId); @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_get(const JsonValue& args, JsonObject& out);
+ void ContactManagerGet(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void update(person); @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_update(const JsonValue& args, JsonObject& out);
+ void ContactManagerUpdate(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void updateBatch(persons, successCallback, errorCallback);
* {status: 'success', result: {persons}}
* @endcode
*/
- void ContactManager_updateBatch(const JsonValue &args, JsonObject &out);
+ void ContactManagerUpdateBatch(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void remove(personId); @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_remove(const JsonValue& args, JsonObject& out);
+ void ContactManagerRemove(const JsonValue& args, JsonObject& out);
/**
- * Signature: @code void removeBatch(personIds, successCallback, errorCallback);
+ * Signature: @code void removeBatch(personIds, successCallback,
+ * errorCallback);
* @endcode
* JSON: @code data: {method: 'ContactManager_removeBatch',
* args: {personsIDs: personIds}} @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_removeBatch(const JsonValue &args, JsonObject &out);
+ void ContactManagerRemoveBatch(const JsonValue& args, JsonObject& out);
/**
- * Signature: @code void find(successCallback, errorCallback, filter, sortMode);
+ * Signature: @code void find(successCallback, errorCallback, filter,
+ * sortMode);
* @endcode
* JSON: @code data: {method: 'ContactManager_find',
* args: {filter: filter, sortMode: sortMode}} @endcode
* {status: 'success', result: {persons}}
* @endcode
*/
- void ContactManager_find(const JsonValue &args, JsonObject &out);
+ void ContactManagerFind(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void getAddressBook(contactString); @endcode
* {status: 'success', result: {contact}}
* @endcode
*/
- void ContactManager_importFromVCard(const JsonValue& args, JsonObject& out);
+ void ContactManagerImportFromVCard(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void getAddressBook(contactString); @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_startListening(const JsonValue& args, JsonObject& out);
+ void ContactManagerStartListening(const JsonValue& args, JsonObject& out);
/**
* Signature: @code void getAddressBook(contactString); @endcode
* {status: 'success'}
* @endcode
*/
- void ContactManager_stopListening(const JsonValue& args, JsonObject& out);
+ void ContactManagerStopListening(const JsonValue& args, JsonObject& out);
-
- void Person_link(const JsonValue& args, JsonObject& out);
- void Person_unlink(const JsonValue& args, JsonObject& out);
+ void PersonLink(const JsonValue& args, JsonObject& out);
+ void PersonUnlink(const JsonValue& args, JsonObject& out);
};
} // namespace contact
} // namespace extension
using namespace common;
-void ContactManager_getAddressBooks(const JsonObject &args, JsonArray &out) {
+void ContactManagerGetAddressBooks(const JsonObject& args, JsonArray& out) {
LoggerD("entered");
ContactUtil::CheckDBConnection();
contacts_list_h address_book_list = nullptr;
- int error_code = contacts_db_get_all_records(_contacts_address_book._uri, 0, 0,
- &address_book_list);
+ int error_code = contacts_db_get_all_records(_contacts_address_book._uri, 0,
+ 0, &address_book_list);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("Fail to get address book list, error: %d", error_code);
throw UnknownException("Fail to get address book list");
}
- ContactUtil::ContactsListHPtr contacts_list_ptr(&address_book_list,
- ContactUtil::ContactsListDeleter);
+ ContactUtil::ContactsListHPtr contacts_list_ptr(
+ &address_book_list, ContactUtil::ContactsListDeleter);
int record_count = 0;
error_code = contacts_list_get_count(*contacts_list_ptr, &record_count);
for (unsigned int i = 0; i < record_count; i++) {
contacts_record_h contacts_record = nullptr;
- error_code = contacts_list_get_current_record_p(*contacts_list_ptr, &contacts_record);
+ error_code = contacts_list_get_current_record_p(*contacts_list_ptr,
+ &contacts_record);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerW("Fail to get address book record");
int id = 0;
int account_id = 0;
int mode = 0;
- char *name = nullptr;
- ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.id, &id);
- ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.account_id, &account_id);
- ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.mode, &mode);
- ContactUtil::GetStrFromRecord(contacts_record, _contacts_address_book.name, &name);
+ char* name = nullptr;
+ ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.id,
+ &id);
+ ContactUtil::GetIntFromRecord(
+ contacts_record, _contacts_address_book.account_id, &account_id);
+ ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.mode,
+ &mode);
+ ContactUtil::GetStrFromRecord(contacts_record, _contacts_address_book.name,
+ &name);
JsonValue single = JsonValue(JsonObject());
- JsonObject &single_obj = single.get<JsonObject>();
+ JsonObject& single_obj = single.get<JsonObject>();
single_obj["id"] = JsonValue(std::to_string(id));
single_obj["accountId"] = JsonValue(static_cast<double>(account_id));
single_obj["name"] = JsonValue(name);
- single_obj["readOnly"] = JsonValue(CONTACTS_ADDRESS_BOOK_MODE_READONLY == mode);
+ single_obj["readOnly"] =
+ JsonValue(CONTACTS_ADDRESS_BOOK_MODE_READONLY == mode);
out.push_back(single);
contacts_list_next(*contacts_list_ptr);
}
}
-void ContactManager_getAddressBook(const JsonObject& args, JsonObject& out) {
+void ContactManagerGetAddressBook(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
long address_book_id;
try {
address_book_id = common::stol(FromJson<JsonString>(args, "addressBookId"));
- } catch (const common::InvalidValuesException&) {
+ }
+ catch (const common::InvalidValuesException&) {
throw common::NotFoundException("Invalid id");
}
contacts_record_h contacts_record;
int error_code = contacts_db_get_record(_contacts_address_book._uri,
- static_cast<int>(address_book_id), &contacts_record);
+ static_cast<int>(address_book_id),
+ &contacts_record);
if (CONTACTS_ERROR_NONE != error_code || nullptr == contacts_record) {
LoggerE("Fail to get addressbook record, error code: %d", error_code);
throw NotFoundException("Fail to get address book with given id");
}
- ContactUtil::ContactsRecordHPtr contacts_record_ptr(&contacts_record,
- ContactUtil::ContactsDeleter);
+ ContactUtil::ContactsRecordHPtr contacts_record_ptr(
+ &contacts_record, ContactUtil::ContactsDeleter);
int account_id;
- ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.account_id, &account_id);
+ ContactUtil::GetIntFromRecord(contacts_record,
+ _contacts_address_book.account_id, &account_id);
int mode;
- ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.mode, &mode);
+ ContactUtil::GetIntFromRecord(contacts_record, _contacts_address_book.mode,
+ &mode);
char* name;
- ContactUtil::GetStrFromRecord(contacts_record, _contacts_address_book.name, &name);
+ ContactUtil::GetStrFromRecord(contacts_record, _contacts_address_book.name,
+ &name);
out.insert(std::make_pair("accountId", static_cast<double>(account_id)));
out.insert(std::make_pair("name", std::string(name)));
- out.insert(std::make_pair("readOnly", (CONTACTS_ADDRESS_BOOK_MODE_READONLY == mode)));
+ out.insert(std::make_pair("readOnly",
+ (CONTACTS_ADDRESS_BOOK_MODE_READONLY == mode)));
}
namespace {
-void ContactManager_get_internal(int person_id, JsonObject* out) {
+void ContactManagerGetInternal(int person_id, JsonObject* out) {
contacts_record_h contacts_record = nullptr;
- int error_code = contacts_db_get_record(_contacts_person._uri, person_id, &contacts_record);
+ int error_code = contacts_db_get_record(_contacts_person._uri, person_id,
+ &contacts_record);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("Person with id: %d, not found, error: %d", person_id, error_code);
throw NotFoundException("Person not found");
}
- ContactUtil::ContactsRecordHPtr contacts_record_ptr(&contacts_record,
- ContactUtil::ContactsDeleter);
+ ContactUtil::ContactsRecordHPtr contacts_record_ptr(
+ &contacts_record, ContactUtil::ContactsDeleter);
ContactUtil::ImportPersonFromContactsRecord(contacts_record, out);
}
}
-void ContactManager_addAddressBook(const JsonObject &args, JsonObject &out) {
+void ContactManagerAddAddressBook(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
- const JsonObject &addressBook = FromJson<JsonObject>(args, "addressBook");
+ const JsonObject& addressBook = FromJson<JsonObject>(args, "addressBook");
if (!IsNull(addressBook, "id")) {
LoggerW("AddressBook already exists");
}
contacts_record_h contacts_record;
- int ret = contacts_record_create(_contacts_address_book._uri, &contacts_record);
+ int ret =
+ contacts_record_create(_contacts_address_book._uri, &contacts_record);
if (CONTACTS_ERROR_NONE != ret) {
LoggerE("Failed to create address book record, error code : %d", ret);
throw UnknownException("Failed to create address book record");
}
- ContactUtil::ContactsRecordHPtr contacts_record_ptr(&contacts_record,
- ContactUtil::ContactsDeleter);
+ ContactUtil::ContactsRecordHPtr contacts_record_ptr(
+ &contacts_record, ContactUtil::ContactsDeleter);
- ContactUtil::SetStrInRecord(contacts_record, _contacts_address_book.name,
+ ContactUtil::SetStrInRecord(
+ contacts_record, _contacts_address_book.name,
FromJson<JsonString>(addressBook, "name").c_str());
- contacts_address_book_mode_e mode = FromJson<bool>(addressBook, "readOnly") ?
- CONTACTS_ADDRESS_BOOK_MODE_READONLY : CONTACTS_ADDRESS_BOOK_MODE_NONE;
+ contacts_address_book_mode_e mode = FromJson<bool>(addressBook, "readOnly")
+ ? CONTACTS_ADDRESS_BOOK_MODE_READONLY
+ : CONTACTS_ADDRESS_BOOK_MODE_NONE;
ContactUtil::SetIntInRecord(contacts_record, _contacts_address_book.mode,
- static_cast<int>(mode));
+ static_cast<int>(mode));
double account_id = FromJson<double>(addressBook, "accountId");
- ContactUtil::SetIntInRecord(contacts_record, _contacts_address_book.account_id,
- static_cast<int>(account_id));
+ ContactUtil::SetIntInRecord(contacts_record,
+ _contacts_address_book.account_id,
+ static_cast<int>(account_id));
int address_book_id;
ret = contacts_db_insert_record(*contacts_record_ptr, &address_book_id);
out.insert(std::make_pair("id", std::to_string(address_book_id)));
}
-void ContactManager_removeAddressBook(const JsonObject &args, JsonObject &out) {
+void ContactManagerRemoveAddressBook(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
long address_book_id;
try {
address_book_id = common::stol(FromJson<JsonString>(args, "addressBookId"));
- } catch (const common::InvalidValuesException&) {
+ }
+ catch (const common::InvalidValuesException&) {
throw common::NotFoundException("Invalid id");
}
contacts_record_h contacts_record;
int error_code = contacts_db_get_record(_contacts_address_book._uri,
- static_cast<int>(address_book_id), &contacts_record);
+ static_cast<int>(address_book_id),
+ &contacts_record);
if (CONTACTS_ERROR_NONE != error_code || nullptr == contacts_record) {
LoggerE("Fail to get addressbook record, error code: %d", error_code);
throw NotFoundException("Fail to get address book with given id");
}
int ret = contacts_db_delete_record(_contacts_address_book._uri,
- static_cast<int>(address_book_id));
+ static_cast<int>(address_book_id));
if (CONTACTS_ERROR_NONE != ret) {
LOGE("Failed to delete address book record, error code : %d", ret);
throw UnknownException("Failed to delete address book record");
}
}
-void ContactManager_get(const JsonObject& args, JsonObject& out) {
+void ContactManagerGet(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
long person_id = common::stol(FromJson<JsonString>(args, "personId"));
- ContactManager_get_internal(person_id, &out);
+ ContactManagerGetInternal(person_id, &out);
}
-void ContactManager_update(const JsonObject& args, JsonObject&) {
+void ContactManagerUpdate(const JsonObject& args, JsonObject&) {
ContactUtil::CheckDBConnection();
const JsonObject& person = FromJson<JsonObject>(args, "person");
long person_id = common::stol(FromJson<JsonString>(person, "id"));
contacts_record_h contacts_record = nullptr;
- int error_code = contacts_db_get_record(_contacts_person._uri, person_id, &contacts_record);
+ int error_code = contacts_db_get_record(_contacts_person._uri, person_id,
+ &contacts_record);
if (CONTACTS_ERROR_NONE != error_code) {
throw NotFoundException("Person not found");
}
}
-void ContactManager_remove(const JsonObject& args, JsonObject&) {
+void ContactManagerRemove(const JsonObject& args, JsonObject&) {
ContactUtil::CheckDBConnection();
long person_id = common::stol(FromJson<JsonString>(args, "personId"));
}
}
-void ContactManager_find(const JsonObject &args, JsonArray &out) {
+void ContactManagerFind(const JsonObject& args, JsonArray& out) {
ContactUtil::CheckDBConnection();
contacts_query_h contacts_query = nullptr;
- int error_code = contacts_query_create(_contacts_person._uri, &contacts_query);
+ int error_code =
+ contacts_query_create(_contacts_person._uri, &contacts_query);
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_create");
- ContactUtil::ContactsQueryHPtr contacts_query_ptr(&contacts_query,
- ContactUtil::ContactsQueryDeleter);
+ ContactUtil::ContactsQueryHPtr contacts_query_ptr(
+ &contacts_query, ContactUtil::ContactsQueryDeleter);
// Add filter to query
- std::vector<std::vector<ContactUtil::ContactsFilterPtr>> intermediate_filters(1);
+ std::vector<std::vector<ContactUtil::ContactsFilterPtr>> intermediate_filters(
+ 1);
if (!IsNull(args, "filter")) {
FilterVisitor visitor;
- visitor.SetOnAttributeFilter([&](const std::string &name,
- AttributeMatchFlag match_flag,
- const JsonValue &match_value) {
+ visitor.SetOnAttributeFilter([&](const std::string& name,
+ AttributeMatchFlag match_flag,
+ const JsonValue& match_value) {
- const Person::PersonProperty &property = Person::PersonProperty_fromString(name);
+ const Person::PersonProperty& property =
+ Person::PersonPropertyFromString(name);
contacts_filter_h contacts_filter = nullptr;
- int error_code = contacts_filter_create(_contacts_person._uri, &contacts_filter);
+ int error_code =
+ contacts_filter_create(_contacts_person._uri, &contacts_filter);
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
ContactUtil::ContactsFilterPtr contacts_filter_ptr(
contacts_filter, ContactUtil::ContactsFilterDeleter);
if (AttributeMatchFlag::kExists != match_flag) {
value = JsonCast<bool>(match_value);
}
- error_code = contacts_filter_add_bool(contacts_filter, property.propertyId, value);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_bool");
+ error_code = contacts_filter_add_bool(contacts_filter,
+ property.propertyId, value);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_bool");
} else if (property.type == kPrimitiveTypeString) {
std::string value = JsonCast<std::string>(match_value);
flag = CONTACTS_MATCH_EXISTS;
value = "";
}
- error_code = contacts_filter_add_str(contacts_filter, property.propertyId,
- flag, value.c_str());
+ error_code = contacts_filter_add_str(
+ contacts_filter, property.propertyId, flag, value.c_str());
ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
} else if (property.type == kPrimitiveTypeLong ||
- property.type == kPrimitiveTypeId) {
+ property.type == kPrimitiveTypeId) {
int value;
if (property.type == kPrimitiveTypeLong) {
value = static_cast<int>(JsonCast<double>(match_value));
flag = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL;
value = 0;
} else if (AttributeMatchFlag::kStartsWith == match_flag ||
- AttributeMatchFlag::kContains == match_flag) {
+ AttributeMatchFlag::kContains == match_flag) {
flag = CONTACTS_MATCH_GREATER_THAN_OR_EQUAL;
} else if (AttributeMatchFlag::kEndsWith == match_flag) {
flag = CONTACTS_MATCH_LESS_THAN_OR_EQUAL;
flag = CONTACTS_MATCH_EQUAL;
}
- error_code = contacts_filter_add_int(contacts_filter, property.propertyId, flag, value);
+ error_code = contacts_filter_add_int(contacts_filter,
+ property.propertyId, flag, value);
ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
} else {
throw UnknownException("Invalid primitive type!");
.push_back(std::move(contacts_filter_ptr));
});
- visitor.SetOnAttributeRangeFilter([&](const std::string &name,
- const JsonValue &initial_value,
- const JsonValue &end_value) {
+ visitor.SetOnAttributeRangeFilter([&](const std::string& name,
+ const JsonValue& initial_value,
+ const JsonValue& end_value) {
- const Person::PersonProperty &property = Person::PersonProperty_fromString(name);
+ const Person::PersonProperty& property =
+ Person::PersonPropertyFromString(name);
contacts_filter_h contacts_filter = nullptr;
- int error_code = contacts_filter_create(_contacts_person._uri, &contacts_filter);
+ int error_code =
+ contacts_filter_create(_contacts_person._uri, &contacts_filter);
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
ContactUtil::ContactsFilterPtr contacts_filter_ptr(
contacts_filter, ContactUtil::ContactsFilterDeleter);
if (initial_value_bool == end_value_bool) {
error_code = contacts_filter_add_bool(
contacts_filter, property.propertyId, initial_value_bool);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_bool");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_bool");
}
} else if (initial_value_exists) {
if (initial_value_bool) {
- error_code = contacts_filter_add_bool(contacts_filter, property.propertyId, true);
+ error_code = contacts_filter_add_bool(contacts_filter,
+ property.propertyId, true);
ContactUtil::ErrorChecker(error_code,
- "Failed contacts_filter_add_bool");
+ "Failed contacts_filter_add_bool");
}
} else if (end_value_exists) {
if (!end_value_bool) {
- error_code = contacts_filter_add_bool(contacts_filter, property.propertyId, false);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_bool");
+ error_code = contacts_filter_add_bool(contacts_filter,
+ property.propertyId, false);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_bool");
}
}
} else if (property.type == kPrimitiveTypeString) {
if (initial_value_exists && end_value_exists) {
contacts_filter_h sub_filter = NULL;
- error_code = contacts_filter_create(_contacts_person._uri, &sub_filter);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
+ error_code =
+ contacts_filter_create(_contacts_person._uri, &sub_filter);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
ContactUtil::ContactsFilterPtr sub_filter_ptr(
sub_filter, ContactUtil::ContactsFilterDeleter);
error_code = contacts_filter_add_str(sub_filter, property.propertyId,
- CONTACTS_MATCH_STARTSWITH,
- initial_value_str.c_str());
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
- error_code = contacts_filter_add_operator(sub_filter,
- CONTACTS_FILTER_OPERATOR_AND);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
+ CONTACTS_MATCH_STARTSWITH,
+ initial_value_str.c_str());
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
+ error_code = contacts_filter_add_operator(
+ sub_filter, CONTACTS_FILTER_OPERATOR_AND);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
error_code = contacts_filter_add_str(sub_filter, property.propertyId,
- CONTACTS_MATCH_ENDSWITH,
- end_value_str.c_str());
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
+ CONTACTS_MATCH_ENDSWITH,
+ end_value_str.c_str());
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
error_code = contacts_filter_add_filter(contacts_filter, sub_filter);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
} else if (initial_value_exists) {
error_code = contacts_filter_add_str(
contacts_filter, property.propertyId, CONTACTS_MATCH_STARTSWITH,
initial_value_str.c_str());
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
} else if (end_value_exists) {
error_code = contacts_filter_add_str(
contacts_filter, property.propertyId, CONTACTS_MATCH_ENDSWITH,
end_value_str.c_str());
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_str");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_str");
}
- } else if (property.type == kPrimitiveTypeLong || property.type == kPrimitiveTypeId) {
+ } else if (property.type == kPrimitiveTypeLong ||
+ property.type == kPrimitiveTypeId) {
int initial_value_int = 0;
int end_value_int = 0;
if (initial_value_exists) {
if (property.type == kPrimitiveTypeLong) {
- initial_value_int = static_cast<int>(JsonCast<double>(initial_value));
+ initial_value_int =
+ static_cast<int>(JsonCast<double>(initial_value));
} else {
- initial_value_int = common::stol(JsonCast<std::string>(initial_value));
+ initial_value_int =
+ common::stol(JsonCast<std::string>(initial_value));
}
}
if (initial_value_exists && end_value_exists) {
contacts_filter_h sub_filter = NULL;
- error_code = contacts_filter_create(_contacts_person._uri, &sub_filter);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_bool");
+ error_code =
+ contacts_filter_create(_contacts_person._uri, &sub_filter);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_bool");
ContactUtil::ContactsFilterPtr sub_filter_ptr(
sub_filter, ContactUtil::ContactsFilterDeleter);
error_code = contacts_filter_add_int(
sub_filter, property.propertyId,
CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, initial_value_int);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_int");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_int");
- error_code = contacts_filter_add_operator(sub_filter,
- CONTACTS_FILTER_OPERATOR_AND);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_operator");
+ error_code = contacts_filter_add_operator(
+ sub_filter, CONTACTS_FILTER_OPERATOR_AND);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_operator");
- error_code = contacts_filter_add_int(sub_filter, property.propertyId,
- CONTACTS_MATCH_LESS_THAN_OR_EQUAL,
- end_value_int);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_int");
+ error_code = contacts_filter_add_int(
+ sub_filter, property.propertyId,
+ CONTACTS_MATCH_LESS_THAN_OR_EQUAL, end_value_int);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_int");
error_code = contacts_filter_add_filter(contacts_filter, sub_filter);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_filter");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_filter");
} else if (initial_value_exists) {
error_code = contacts_filter_add_int(
contacts_filter, property.propertyId,
CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, initial_value_int);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_int");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_int");
} else if (end_value_exists) {
error_code = contacts_filter_add_int(
contacts_filter, property.propertyId,
CONTACTS_MATCH_LESS_THAN_OR_EQUAL, end_value_int);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_filter_add_int");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_filter_add_int");
}
} else {
throw UnknownException("Invalid primitive type!");
});
visitor.SetOnCompositeFilterBegin([&](CompositeFilterType type) {
- intermediate_filters.push_back(std::vector<ContactUtil::ContactsFilterPtr>());
+ intermediate_filters.push_back(
+ std::vector<ContactUtil::ContactsFilterPtr>());
});
visitor.SetOnCompositeFilterEnd([&](CompositeFilterType type) {
}
contacts_filter_h merged_filter = nullptr;
- int error_code = contacts_filter_create(_contacts_person._uri, &merged_filter);
+ int error_code =
+ contacts_filter_create(_contacts_person._uri, &merged_filter);
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
ContactUtil::ContactsFilterPtr merged_filter_ptr(
merged_filter, ContactUtil::ContactsFilterDeleter);
for (std::size_t i = 0; i < intermediate_filters.back().size(); ++i) {
error_code = contacts_filter_add_filter(
merged_filter, intermediate_filters.back().at(i).get());
- ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_query_set_filter");
if (CompositeFilterType::kIntersection == type) {
- error_code = contacts_filter_add_operator(merged_filter,
- CONTACTS_FILTER_OPERATOR_AND);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
+ error_code = contacts_filter_add_operator(
+ merged_filter, CONTACTS_FILTER_OPERATOR_AND);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_query_set_filter");
} else if (CompositeFilterType::kUnion == type) {
- error_code = contacts_filter_add_operator(merged_filter,
- CONTACTS_FILTER_OPERATOR_OR);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
+ error_code = contacts_filter_add_operator(
+ merged_filter, CONTACTS_FILTER_OPERATOR_OR);
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_query_set_filter");
} else {
throw InvalidValuesException("Invalid union type!");
}
visitor.Visit(FromJson<JsonObject>(args, "filter"));
// Should compute only one filter always.
- if ((intermediate_filters.size() != 1) || (intermediate_filters[0].size() != 1)) {
+ if ((intermediate_filters.size() != 1) ||
+ (intermediate_filters[0].size() != 1)) {
LoggerE("Bad filter evaluation!");
throw UnknownException("Bad filter evaluation!");
}
// Filter is generated
- error_code = contacts_query_set_filter(contacts_query, intermediate_filters[0][0].get());
+ error_code = contacts_query_set_filter(contacts_query,
+ intermediate_filters[0][0].get());
ContactUtil::ErrorChecker(error_code, "Failed contacts_query_set_filter");
}
contacts_list_h person_list = nullptr;
- error_code = contacts_db_get_records_with_query(contacts_query, 0, 0, &person_list);
+ error_code =
+ contacts_db_get_records_with_query(contacts_query, 0, 0, &person_list);
- ContactUtil::ErrorChecker(error_code, "Failed contacts_db_get_records_with_query");
+ ContactUtil::ErrorChecker(error_code,
+ "Failed contacts_db_get_records_with_query");
- ContactUtil::ContactsListHPtr person_list_ptr(&person_list, ContactUtil::ContactsListDeleter);
+ ContactUtil::ContactsListHPtr person_list_ptr(
+ &person_list, ContactUtil::ContactsListDeleter);
int record_count = 0;
error_code = contacts_list_get_count(person_list, &record_count);
for (unsigned int i = 0; i < record_count; i++) {
contacts_record_h contacts_record;
- error_code = contacts_list_get_current_record_p(person_list, &contacts_record);
+ error_code =
+ contacts_list_get_current_record_p(person_list, &contacts_record);
if (error_code != CONTACTS_ERROR_NONE || contacts_record == NULL) {
LoggerW("Failed group record (ret:%d)", error_code);
continue;
}
int id_value = 0;
- error_code = contacts_record_get_int(contacts_record, _contacts_person.id, &id_value);
+ error_code = contacts_record_get_int(contacts_record, _contacts_person.id,
+ &id_value);
ContactUtil::ErrorChecker(error_code, "Failed contacts_record_get_int");
}
}
-void ContactManager_importFromVCard(const JsonObject& args, JsonObject& out) {
+void ContactManagerImportFromVCard(const JsonObject& args, JsonObject& out) {
// I'm not sure how to call it. Should it be 'Contact', 'vCard' or what?
ContactUtil::CheckDBConnection();
const char* vcard_char_ptr = FromJson<JsonString>(args, "contact").c_str();
return true;
}
-void ContactManager_listenerCallback(const char* view_uri, char* changes,
- void* user_data) {
+void ContactManagerListenerCallback(const char* view_uri, char* changes,
+ void* user_data) {
(void)view_uri;
(void)user_data;
JsonObject& result_obj = result.get<JsonObject>();
result_obj.insert(std::make_pair("listenerId", kContactPersonListenerId));
JsonArray& added = result_obj.insert(std::make_pair("added", JsonArray{}))
+ .first->second.get<JsonArray>();
+ JsonArray& updated = result_obj.insert(std::make_pair("updated", JsonArray{}))
+ .first->second.get<JsonArray>();
+ JsonArray& removed = result_obj.insert(std::make_pair("removed", JsonArray{}))
.first->second.get<JsonArray>();
- JsonArray& updated =
- result_obj.insert(std::make_pair("updated", JsonArray{}))
- .first->second.get<JsonArray>();
- JsonArray& removed =
- result_obj.insert(std::make_pair("removed", JsonArray{}))
- .first->second.get<JsonArray>();
std::unique_ptr<char, void (*)(char*)> tmp(strdup(changes),
[](char* p) { free(p); });
switch (type) {
case CONTACTS_CHANGE_INSERTED: {
added.push_back(JsonValue{JsonObject{}});
- ContactManager_get_internal(person_id,
- &added.back().get<JsonObject>());
+ ContactManagerGetInternal(person_id,
+ &added.back().get<JsonObject>());
break;
}
case CONTACTS_CHANGE_UPDATED: {
updated.push_back(JsonValue{JsonObject{}});
- ContactManager_get_internal(person_id,
- &updated.back().get<JsonObject>());
+ ContactManagerGetInternal(person_id,
+ &updated.back().get<JsonObject>());
break;
}
case CONTACTS_CHANGE_DELETED: {
}
}
-void ContactManager_startListening(const JsonObject& /*args*/, JsonObject& /*out*/) {
+void ContactManagerStartListening(const JsonObject& /*args*/,
+ JsonObject& /*out*/) {
ContactUtil::CheckDBConnection();
int error_code = contacts_db_add_changed_cb_with_info(
- _contacts_person._uri, ContactManager_listenerCallback, nullptr);
+ _contacts_person._uri, ContactManagerListenerCallback, nullptr);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("contacts_db_add_changed_cb(_contacts_person._uri) error: %d",
}
}
-void ContactManager_stopListening(const JsonObject& /*args*/, JsonObject& /*out*/) {
+void ContactManagerStopListening(const JsonObject& /*args*/,
+ JsonObject& /*out*/) {
ContactUtil::CheckDBConnection();
int error_code = contacts_db_remove_changed_cb_with_info(
- _contacts_person._uri, ContactManager_listenerCallback, nullptr);
+ _contacts_person._uri, ContactManagerListenerCallback, nullptr);
if (CONTACTS_ERROR_NONE != error_code) {
LoggerE("contacts_db_remove_changed_cb(_contacts_person._uri) error: %d",
namespace contact {
namespace ContactManager {
-void ContactManager_getAddressBooks(const JsonObject& args, JsonArray& out);
+void ContactManagerGetAddressBooks(const JsonObject& args, JsonArray& out);
-void ContactManager_getAddressBook(const JsonObject& args, JsonObject& out);
+void ContactManagerGetAddressBook(const JsonObject& args, JsonObject& out);
-void ContactManager_addAddressBook(const JsonObject& args, JsonObject& out);
+void ContactManagerAddAddressBook(const JsonObject& args, JsonObject& out);
-void ContactManager_removeAddressBook(const JsonObject& args, JsonObject& out);
+void ContactManagerRemoveAddressBook(const JsonObject& args, JsonObject& out);
-void ContactManager_get(const JsonObject& args, JsonObject& out);
+void ContactManagerGet(const JsonObject& args, JsonObject& out);
-void ContactManager_update(const JsonObject& args, JsonObject&);
+void ContactManagerUpdate(const JsonObject& args, JsonObject&);
-void ContactManager_updateBatch(const JsonObject& args, JsonObject& out);
+void ContactManagerUpdateBatch(const JsonObject& args, JsonObject& out);
-void ContactManager_remove(const JsonObject& args, JsonObject&);
+void ContactManagerRemove(const JsonObject& args, JsonObject&);
-void ContactManager_removeBatch(const JsonObject& args, JsonObject& out);
+void ContactManagerRemoveBatch(const JsonObject& args, JsonObject& out);
-void ContactManager_find(const JsonObject &args, JsonArray &out);
+void ContactManagerFind(const JsonObject& args, JsonArray& out);
-void ContactManager_importFromVCard(const JsonObject& args, JsonObject& out);
+void ContactManagerImportFromVCard(const JsonObject& args, JsonObject& out);
/**
* Signature: @code void getAddressBook(contactString); @endcode
* {status: 'success'}
* @endcode
*/
-void ContactManager_startListening(const JsonObject& args, JsonObject& out);
+void ContactManagerStartListening(const JsonObject& args, JsonObject& out);
/**
* Signature: @code void getAddressBook(contactString); @endcode
* {status: 'success'}
* @endcode
*/
-void ContactManager_stopListening(const JsonObject& args, JsonObject& out);
+void ContactManagerStopListening(const JsonObject& args, JsonObject& out);
} // namespace ContactManager
} // namespace contact
using namespace common;
static const PersonPropertyMap personPropertyMap = {
- {"id", { _contacts_person.id, kPrimitiveTypeId } },
- {"displayName", { _contacts_person.display_name, kPrimitiveTypeString } },
- {"contactCount", { _contacts_person.link_count, kPrimitiveTypeLong } },
- {"hasPhoneNumber", { _contacts_person.has_phonenumber, kPrimitiveTypeBoolean } },
- {"hasEmail", { _contacts_person.has_email, kPrimitiveTypeBoolean } },
- {"isFavorite", { _contacts_person.is_favorite, kPrimitiveTypeBoolean } },
- {"photoURI", { _contacts_person.image_thumbnail_path,kPrimitiveTypeString } },
- {"ringtoneURI", { _contacts_person.ringtone_path, kPrimitiveTypeString } },
- {"displayContactId", { _contacts_person.display_contact_id, kPrimitiveTypeId } },
-};
-
-void Person_link(const JsonObject& args, JsonObject&) {
+ {"id", {_contacts_person.id, kPrimitiveTypeId}},
+ {"displayName", {_contacts_person.display_name, kPrimitiveTypeString}},
+ {"contactCount", {_contacts_person.link_count, kPrimitiveTypeLong}},
+ {"hasPhoneNumber",
+ {_contacts_person.has_phonenumber, kPrimitiveTypeBoolean}},
+ {"hasEmail", {_contacts_person.has_email, kPrimitiveTypeBoolean}},
+ {"isFavorite", {_contacts_person.is_favorite, kPrimitiveTypeBoolean}},
+ {"photoURI", {_contacts_person.image_thumbnail_path, kPrimitiveTypeString}},
+ {"ringtoneURI", {_contacts_person.ringtone_path, kPrimitiveTypeString}},
+ {"displayContactId",
+ {_contacts_person.display_contact_id, kPrimitiveTypeId}}, };
+
+void PersonLink(const JsonObject& args, JsonObject&) {
ContactUtil::CheckDBConnection();
long id = common::stol(FromJson<JsonString>(args, "id"));
ContactUtil::ErrorChecker(err, "Error during executing person link()");
}
-void Person_unlink(const JsonObject& args, JsonObject& out) {
+void PersonUnlink(const JsonObject& args, JsonObject& out) {
ContactUtil::CheckDBConnection();
long contact_id = common::stol(FromJson<JsonString>(args, "id"));
contacts_record = nullptr;
}
-const PersonProperty& PersonProperty_fromString(const std::string& name) {
+const PersonProperty& PersonPropertyFromString(const std::string& name) {
auto iter = personPropertyMap.find(name);
if (iter == personPropertyMap.end()) {
LoggerE("Invalid property name (not in map): %s", name.c_str());
namespace contact {
enum PrimitiveType {
- kPrimitiveTypeBoolean,
- kPrimitiveTypeString,
- kPrimitiveTypeLong,
- kPrimitiveTypeId
+ kPrimitiveTypeBoolean,
+ kPrimitiveTypeString,
+ kPrimitiveTypeLong,
+ kPrimitiveTypeId
};
namespace Person {
typedef std::map<std::string, PersonProperty> PersonPropertyMap;
-const PersonProperty& PersonProperty_fromString(const std::string& name);
+const PersonProperty& PersonPropertyFromString(const std::string& name);
-void Person_link(const JsonObject& args, JsonObject&);
-void Person_unlink(const JsonObject& args, JsonObject&);
+void PersonLink(const JsonObject& args, JsonObject&);
+void PersonUnlink(const JsonObject& args, JsonObject&);
} // Person
} // contact