From fc32aa300d112c3262af7392e5f57b5edf7cbeb8 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Fri, 13 Feb 2015 14:45:56 +0100 Subject: [PATCH] [SystemSetting] Adjust code to google style. [Verification] Code compiles without error. Change-Id: Ic9a43f103f6bc66a6b74af8849436f7b0083db58 Signed-off-by: Lukasz Bardeli --- src/systemsetting/systemsetting_instance.cc | 252 ++++++++++---------- src/systemsetting/systemsetting_instance.h | 28 +-- 2 files changed, 140 insertions(+), 140 deletions(-) diff --git a/src/systemsetting/systemsetting_instance.cc b/src/systemsetting/systemsetting_instance.cc index b1d412ca..2efb13bb 100644 --- a/src/systemsetting/systemsetting_instance.cc +++ b/src/systemsetting/systemsetting_instance.cc @@ -28,13 +28,13 @@ using namespace extension::systemsetting; SystemSettingInstance::SystemSettingInstance() { - using namespace std::placeholders; + using namespace std::placeholders; #define REGISTER(c,x) \ -RegisterHandler(c, std::bind(&SystemSettingInstance::x, this, _1, _2)); + RegisterHandler(c, std::bind(&SystemSettingInstance::x, this, _1, _2)); - REGISTER("SystemSettingManager_getProperty", getProperty); - REGISTER("SystemSettingManager_setProperty", setProperty); + REGISTER("SystemSettingManager_getProperty", getProperty); + REGISTER("SystemSettingManager_setProperty", setProperty); #undef REGISTER } @@ -45,139 +45,139 @@ SystemSettingInstance::~SystemSettingInstance() void SystemSettingInstance::getProperty(const picojson::value& args, picojson::object& out) { - LoggerD(""); - const double callback_id = args.get("callbackId").get(); - - const std::string& type = args.get("type").get(); - LoggerD("Getting property type: %s ", type.c_str()); - - auto get = [this, type](const std::shared_ptr& response) -> void { - LoggerD("Getting platform value"); - picojson::value result = picojson::value(picojson::object()); - PlatformResult status = getPlatformPropertyValue(type, &result); - if(status.IsSuccess()) - ReportSuccess(result, response->get()); - else - ReportError(status, &response->get()); - }; - - auto get_response = [this, callback_id](const std::shared_ptr& response) -> void { - LoggerD("Getting response"); - picojson::object& obj = response->get(); - obj.insert(std::make_pair("callbackId", callback_id)); - PostMessage(response->serialize().c_str()); - }; - - TaskQueue::GetInstance().Queue - (get, get_response, std::shared_ptr(new picojson::value(picojson::object()))); + LoggerD(""); + const double callback_id = args.get("callbackId").get(); + + const std::string& type = args.get("type").get(); + LoggerD("Getting property type: %s ", type.c_str()); + + auto get = [this, type](const std::shared_ptr& response) -> void { + LoggerD("Getting platform value"); + picojson::value result = picojson::value(picojson::object()); + PlatformResult status = getPlatformPropertyValue(type, &result); + if(status.IsSuccess()) + ReportSuccess(result, response->get()); + else + ReportError(status, &response->get()); + }; + + auto get_response = [this, callback_id](const std::shared_ptr& response) -> void { + LoggerD("Getting response"); + picojson::object& obj = response->get(); + obj.insert(std::make_pair("callbackId", callback_id)); + PostMessage(response->serialize().c_str()); + }; + + TaskQueue::GetInstance().Queue + (get, get_response, std::shared_ptr(new picojson::value(picojson::object()))); } PlatformResult SystemSettingInstance::getPlatformPropertyValue( - const std::string& settingType, - picojson::value* out) { - picojson::object& result_obj = out->get(); - - int ret; - char *value = NULL; - if (settingType == SETTING_HOME_SCREEN) { - ret = system_settings_get_value_string( - SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &value); - } - else if (settingType == SETTING_LOCK_SCREEN) { - ret = system_settings_get_value_string( - SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value); - } - else if (settingType == SETTING_INCOMING_CALL) { - ret = system_settings_get_value_string( - SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &value); - } - else if (settingType == SETTING_NOTIFICATION_EMAIL) { - ret = system_settings_get_value_string( - SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &value); - } - // other values (not specified in the documentation) are handled in JS - - switch (ret) { - case SYSTEM_SETTINGS_ERROR_NONE: - LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE"); - result_obj.insert(std::make_pair("value", value)); - free(value); - return PlatformResult(ErrorCode::NO_ERROR); - case SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API: - LoggerD("ret == SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API"); - return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, - "This property is not supported."); - default: - LoggerD("Other error"); - return PlatformResult(ErrorCode::UNKNOWN_ERR); + const std::string& settingType, + picojson::value* out) { + picojson::object& result_obj = out->get(); + + int ret; + char *value = NULL; + if (settingType == SETTING_HOME_SCREEN) { + ret = system_settings_get_value_string( + SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, &value); + } + else if (settingType == SETTING_LOCK_SCREEN) { + ret = system_settings_get_value_string( + SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &value); + } + else if (settingType == SETTING_INCOMING_CALL) { + ret = system_settings_get_value_string( + SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &value); + } + else if (settingType == SETTING_NOTIFICATION_EMAIL) { + ret = system_settings_get_value_string( + SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, &value); + } + // other values (not specified in the documentation) are handled in JS + + switch (ret) { + case SYSTEM_SETTINGS_ERROR_NONE: + LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE"); + result_obj.insert(std::make_pair("value", value)); + free(value); + return PlatformResult(ErrorCode::NO_ERROR); + case SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API: + LoggerD("ret == SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API"); + return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, + "This property is not supported."); + default: + LoggerD("Other error"); + return PlatformResult(ErrorCode::UNKNOWN_ERR); } } void SystemSettingInstance::setProperty(const picojson::value& args, picojson::object& out) { - LoggerD(""); - const double callback_id = args.get("callbackId").get(); - - const std::string& type = args.get("type").get(); - LoggerD("Type to set: %s ", type.c_str()); - - const std::string& value = args.get("value").get(); - LoggerD("Value to set: %s ", value.c_str()); - - auto get = [this, type, value](const std::shared_ptr& response) -> void { - LoggerD("Setting platform value"); - PlatformResult status = setPlatformPropertyValue(type, value); - if (status.IsSuccess()) - ReportSuccess(response->get()); - else - ReportError(status, &response->get()); - }; - - auto get_response = [this, callback_id](const std::shared_ptr& response) -> void { - LoggerD("Getting response"); - picojson::object& obj = response->get(); - obj.insert(std::make_pair("callbackId", callback_id)); - PostMessage(response->serialize().c_str()); - }; - - TaskQueue::GetInstance().Queue - (get, get_response, std::shared_ptr(new picojson::value(picojson::object()))); + LoggerD(""); + const double callback_id = args.get("callbackId").get(); + + const std::string& type = args.get("type").get(); + LoggerD("Type to set: %s ", type.c_str()); + + const std::string& value = args.get("value").get(); + LoggerD("Value to set: %s ", value.c_str()); + + auto get = [this, type, value](const std::shared_ptr& response) -> void { + LoggerD("Setting platform value"); + PlatformResult status = setPlatformPropertyValue(type, value); + if (status.IsSuccess()) + ReportSuccess(response->get()); + else + ReportError(status, &response->get()); + }; + + auto get_response = [this, callback_id](const std::shared_ptr& response) -> void { + LoggerD("Getting response"); + picojson::object& obj = response->get(); + obj.insert(std::make_pair("callbackId", callback_id)); + PostMessage(response->serialize().c_str()); + }; + + TaskQueue::GetInstance().Queue + (get, get_response, std::shared_ptr(new picojson::value(picojson::object()))); } PlatformResult SystemSettingInstance::setPlatformPropertyValue( - const std::string& settingType, - const std::string& settingValue) { - int ret; - if (settingType == SETTING_HOME_SCREEN) { - ret = system_settings_set_value_string( - SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, settingValue.c_str()); - } - else if (settingType == SETTING_LOCK_SCREEN) { - ret = system_settings_set_value_string( - SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, settingValue.c_str()); - } - else if (settingType == SETTING_INCOMING_CALL) { - ret = system_settings_set_value_string( - SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, settingValue.c_str()); - } - else if (settingType == SETTING_NOTIFICATION_EMAIL) { - ret = system_settings_set_value_string( - SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, settingValue.c_str()); - } - // other values (not specified in the documentation) are handled in JS - - switch (ret) { - case SYSTEM_SETTINGS_ERROR_NONE: - LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE"); - return PlatformResult(ErrorCode::NO_ERROR); - case SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API: - LoggerD("ret == SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API"); - return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, - "This property is not supported."); - default: - LoggerD("Other error"); - return PlatformResult(ErrorCode::UNKNOWN_ERR); - } + const std::string& settingType, + const std::string& settingValue) { + int ret; + if (settingType == SETTING_HOME_SCREEN) { + ret = system_settings_set_value_string( + SYSTEM_SETTINGS_KEY_WALLPAPER_HOME_SCREEN, settingValue.c_str()); + } + else if (settingType == SETTING_LOCK_SCREEN) { + ret = system_settings_set_value_string( + SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, settingValue.c_str()); + } + else if (settingType == SETTING_INCOMING_CALL) { + ret = system_settings_set_value_string( + SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, settingValue.c_str()); + } + else if (settingType == SETTING_NOTIFICATION_EMAIL) { + ret = system_settings_set_value_string( + SYSTEM_SETTINGS_KEY_EMAIL_ALERT_RINGTONE, settingValue.c_str()); + } + // other values (not specified in the documentation) are handled in JS + + switch (ret) { + case SYSTEM_SETTINGS_ERROR_NONE: + LoggerD("ret == SYSTEM_SETTINGS_ERROR_NONE"); + return PlatformResult(ErrorCode::NO_ERROR); + case SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API: + LoggerD("ret == SYSTEM_SETTINGS_ERROR_CALL_UNSUPPORTED_API"); + return PlatformResult(ErrorCode::NOT_SUPPORTED_ERR, + "This property is not supported."); + default: + LoggerD("Other error"); + return PlatformResult(ErrorCode::UNKNOWN_ERR); + } } } // namespace systemsetting diff --git a/src/systemsetting/systemsetting_instance.h b/src/systemsetting/systemsetting_instance.h index 8ad8e2bf..edbe7324 100644 --- a/src/systemsetting/systemsetting_instance.h +++ b/src/systemsetting/systemsetting_instance.h @@ -13,20 +13,20 @@ namespace systemsetting { class SystemSettingInstance : public common::ParsedInstance { -public: - SystemSettingInstance(); - virtual ~SystemSettingInstance(); - -private: - void getProperty(const picojson::value& args, picojson::object& out); - common::PlatformResult getPlatformPropertyValue( - const std::string& valueType, - picojson::value* out); - - void setProperty(const picojson::value& args, picojson::object& out); - common::PlatformResult setPlatformPropertyValue( - const std::string& settingType, - const std::string& settingValue); + public: + SystemSettingInstance(); + virtual ~SystemSettingInstance(); + + private: + void getProperty(const picojson::value& args, picojson::object& out); + common::PlatformResult getPlatformPropertyValue( + const std::string& valueType, + picojson::value* out); + + void setProperty(const picojson::value& args, picojson::object& out); + common::PlatformResult setPlatformPropertyValue( + const std::string& settingType, + const std::string& settingValue); }; } // namespace systemsetting -- 2.34.1