From: Kamil Lysik Date: Tue, 24 Mar 2015 10:08:38 +0000 (+0100) Subject: [Application] Add launchMode to launchAppControl X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~184 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c0d54e60b4f9e074ee71a23bbc7016f5f919b3b1;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Application] Add launchMode to launchAppControl Due to change in native API, a change is proposed to introduce launchMode into launchAppControl. Change-Id: Iaeddec76be830fe1e465f02c4a46a7996abc0168 Signed-off-by: Kamil Lysik --- diff --git a/src/application/application_api.js b/src/application/application_api.js index 8c9ac78b..104ded8d 100644 --- a/src/application/application_api.js +++ b/src/application/application_api.js @@ -9,6 +9,11 @@ var validator_ = xwalk.utils.validator; var types_ = validator_.Types; var native_ = new xwalk.utils.NativeManager(extension); +var ApplicationControlLaunchMode = { + SINGLE: 'SINGLE', + GROUP: 'GROUP' +}; + function callNative(cmd, args) { var result = native_.callSync(cmd, args); @@ -184,6 +189,9 @@ ApplicationManager.prototype.launchAppControl = function(appControl, id, success if (args['appControl']) { nativeParam['appControl'] = args.appControl; } + if (args.appControl['launchMode'] ) { + nativeParam['launchMode'] = args.appControl['launchMode']; + } //Try to find application try { @@ -519,7 +527,7 @@ tizen.ApplicationControlData = function(key, value) { } }; -tizen.ApplicationControl = function(operation, uri, mime, category, data) { +tizen.ApplicationControl = function(operation, uri, mime, category, data, launchMode) { if (this && this.constructor === tizen.ApplicationControl && (typeof(operation) === 'string' || operation instanceof String)) { @@ -528,6 +536,7 @@ tizen.ApplicationControl = function(operation, uri, mime, category, data) { defineReadWriteProperty(this, 'mime', mime); defineReadWriteProperty(this, 'category', category); defineReadWriteProperty(this, 'data', data); + defineReadWriteProperty(this, 'data', launchMode); } else { throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR); diff --git a/src/application/application_instance.cc b/src/application/application_instance.cc index 7128cb0a..bbbe515e 100644 --- a/src/application/application_instance.cc +++ b/src/application/application_instance.cc @@ -480,6 +480,7 @@ static char* getPackageByAppId(const char* app_id) { LoggerE("Fail to get pkgName"); pkgName = NULL; } + ret = app_info_destroy(handle); if (ret < 0) { LoggerE("Fail to get destory appinfo"); @@ -1060,13 +1061,17 @@ void ApplicationInstance::AppMgrLaunchAppControl(const picojson::value& args, CHECK_EXIST(args, "callbackId", out) int callback_id = static_cast(args.get("callbackId").get()); + LoggerD("callbackId = %d", callback_id); std::string id; // app id is optional if (args.contains("id")) { id = args.get("id").get(); LoggerD("app_id = %s", id.c_str()); } - LoggerD("callbackId = %d", callback_id); - + std::string launchMode; // launch mode is optional + if (args.contains("launchMode")) { + launchMode = args.get("launchMode").get(); + LoggerD("launchMode = %s", launchMode.c_str()); + } ApplicationControlPtr app_ctr_ptr(new ApplicationControl()); picojson::value app_control = args.get("appControl"); @@ -1155,6 +1160,26 @@ void ApplicationInstance::AppMgrLaunchAppControl(const picojson::value& args, LoggerD("app_id is empty"); } + if (!launchMode.empty()) { + app_control_launch_mode_e launch_mode; + if (launchMode == "SINGLE") { + launch_mode = APP_CONTROL_LAUNCH_MODE_SINGLE; + } else if (launchMode == "GROUP") { + launch_mode = APP_CONTROL_LAUNCH_MODE_SINGLE; + } else { + LoggerE("Invalid launch mode!"); + ReportError(UnknownException("Invalid launch mode"), out); + app_control_destroy(service); + return; + } + ret = app_control_set_launch_mode(service, launch_mode); + if (ret != APP_CONTROL_ERROR_NONE) { + ReportError(UnknownException("Setting app_id is failed."), out); + app_control_destroy(service); + return; + } + } + ret = app_control_set_operation(service, operation.c_str()); if (ret != APP_CONTROL_ERROR_NONE) { ReportError(InvalidValuesException("operation is invalid parameter"), out);