From: Pawel Wasowski Date: Fri, 2 Nov 2018 14:39:33 +0000 (+0100) Subject: [Application] Fix ApplicationControl object construction and logs X-Git-Tag: submit/tizen_5.0/20181126.103411~8^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3abf57744f689b2f6fb0056f30ab21eae8d1f10a;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Application] Fix ApplicationControl object construction and logs This commit fixes 2 issues of ApplicationUtils::ServiceToApplicationControl function: 1. launchMode field of JS ApplicationControl object was not filled. Now, this field is filled properly. 2. valid, empty values, obtained from app_control_h object were logged as erroneous. Now they are logged as empty. [Verification] TCT pass rate: 100% Change-Id: I6589d73ccebc35fbede0c9fac6b663b376970174 Signed-off-by: Pawel Wasowski --- diff --git a/src/application/application_utils.cc b/src/application/application_utils.cc index 596d292a..4a0098af 100644 --- a/src/application/application_utils.cc +++ b/src/application/application_utils.cc @@ -295,39 +295,59 @@ void ApplicationUtils::ServiceToApplicationControl(app_control_h app_control, }; ret = app_control_get_operation(app_control, &tmp_str); - if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) { + if (APP_CONTROL_ERROR_NONE != ret) { + LoggerE("Get operation failed: %d (%s)", ret, get_error_message(ret)); + } else if (tmp_str) { LoggerD("operation: %s", tmp_str); app_control_obj->insert(std::make_pair("operation", picojson::value(std::string(tmp_str)))); } else { - LoggerE("Get operation failed: %d (%s)", ret, get_error_message(ret)); + LoggerD("operation field is empty"); } clear(tmp_str); ret = app_control_get_uri(app_control, &tmp_str); - if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) { + if (APP_CONTROL_ERROR_NONE != ret) { + LoggerE("Get URI failed: %d (%s)", ret, get_error_message(ret)); + } else if (tmp_str) { LoggerD("URI: %s", tmp_str); app_control_obj->insert(std::make_pair("uri", picojson::value(std::string(tmp_str)))); + } else { + LoggerD("URI field is empty"); } clear(tmp_str); ret = app_control_get_mime(app_control, &tmp_str); - if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) { + if (APP_CONTROL_ERROR_NONE != ret) { + LoggerE("Get MIME failed: %d (%s)", ret, get_error_message(ret)); + } else if (tmp_str) { LoggerD("MIME: %s", tmp_str); app_control_obj->insert(std::make_pair("mime", picojson::value(std::string(tmp_str)))); } else { - LoggerE("Get mime failed: %d (%s)", ret, get_error_message(ret)); + LoggerD("MIME field is empty"); } clear(tmp_str); ret = app_control_get_category(app_control, &tmp_str); - if ((APP_CONTROL_ERROR_NONE == ret) && (nullptr != tmp_str)) { + if (APP_CONTROL_ERROR_NONE != ret) { + LoggerE("Get category failed: %d (%s)", ret, get_error_message(ret)); + } else if (tmp_str) { LoggerD("category: %s", tmp_str); app_control_obj->insert(std::make_pair("category", picojson::value(std::string(tmp_str)))); } else { - LoggerE("Get category failed: %d (%s)", ret, get_error_message(ret)); + LoggerD("category field is empty"); } clear(tmp_str); + app_control_launch_mode_e launch_mode = APP_CONTROL_LAUNCH_MODE_SINGLE; + ret = app_control_get_launch_mode(app_control, &launch_mode); + if (APP_CONTROL_ERROR_NONE != ret) { + LoggerE("Get launch mode failed: %d (%s)", ret, get_error_message(ret)); + } else { + std::string launch_mode_str = launch_mode == APP_CONTROL_LAUNCH_MODE_SINGLE ? "SINGLE" : "GROUP"; + LoggerD("launch mode: %s", launch_mode_str.c_str()); + app_control_obj->insert(std::make_pair("launchMode", picojson::value(launch_mode_str))); + } + app_control_obj->insert(std::make_pair("data", picojson::value(picojson::array()))); ServiceToApplicationControlDataArray( app_control, &app_control_obj->find("data")->second.get());