From 4b61ef8da4a5102ca0adf7d61f49955123d190ce Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Thu, 5 Jan 2017 08:59:08 +0100 Subject: [PATCH] [Convergence] Added checking if service is started. [Verification] Code compiles. Function successfully tested in chrome console. Change-Id: Ic1ee1b6cd182d4aa09d924d96435f07d71c3fe11 Signed-off-by: Tomasz Marciniak --- .../convergence_remote_app_control_service.cc | 34 +++++++++++++++++----- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/convergence/convergence_remote_app_control_service.cc b/src/convergence/convergence_remote_app_control_service.cc index 89b1201..23bb6b6 100644 --- a/src/convergence/convergence_remote_app_control_service.cc +++ b/src/convergence/convergence_remote_app_control_service.cc @@ -34,6 +34,7 @@ static const char* kAppControl = "app_control"; static const char* kReply = "reply"; static const char* kCbResult = "callback_result"; static const char* kRemoteFunc = "remote_function"; +static const char* kJSCurrentListenerId = "curListenerId"; static const std::string kLaunch = "launch"; static const std::string kLaunchAppControl = "launchAppControl"; @@ -161,15 +162,34 @@ TizenResult ConvergenceRemoteAppControlService::Start(const bool reply, const in return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); } - if (reply) { - UpdateListener(cur_listener_id); - } + bool is_started = false; + //regarding to native team returned value should not be checked + //as CONV_ERROR_NONE means service is started, otherwise not started + //check only passed bool variable + conv_service_is_started(service, nullptr, &is_started); - const int error = conv_service_start(service, nullptr, nullptr); - if (CONV_ERROR_NONE != error) { - return LogAndCreateTizenError(AbortError, "conv_service_start error"); + if (is_started) { + //just call success callback + picojson::object param; + param[kServiceResultType] = picojson::value("onStart"); + param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); + param[kJSCurrentListenerId] = picojson::value(static_cast(cur_listener_id)); + + convergence_plugin_->ReplyAsync(kRemoteAppControlListenerCallback, + cur_listener_id, + true, + param); } else { - LoggerI("RemoteAppControlService started"); + if (reply) { + UpdateListener(cur_listener_id); + } + + const int error = conv_service_start(service, nullptr, nullptr); + if (CONV_ERROR_NONE != error) { + return LogAndCreateTizenError(AbortError, "conv_service_start error"); + } else { + LoggerI("RemoteAppControlService started"); + } } return TizenSuccess(); -- 2.7.4