From: Andrzej Popowski Date: Mon, 9 Jan 2017 07:31:40 +0000 (+0100) Subject: [Convergence] - adding conv_service_is_started to AppCommunicationService X-Git-Tag: submit/tizen_3.0/20170111.021729~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d083aa4f971ff160034262e5d3b0de77527fa92;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Convergence] - adding conv_service_is_started to AppCommunicationService Change-Id: I7fbf4412805b9e7ecaf0326c84016c8441e3d2c4 Signed-off-by: Andrzej Popowski --- diff --git a/src/convergence/convergence_app_communication_service.cc b/src/convergence/convergence_app_communication_service.cc index 2b71890b..5d404510 100644 --- a/src/convergence/convergence_app_communication_service.cc +++ b/src/convergence/convergence_app_communication_service.cc @@ -73,14 +73,32 @@ common::TizenResult ConvergenceAppCommunicationService::Start( return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); } - UpdateListener(cur_listener_id, REMOTE_SERVICE_START); + 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_handle, channel->GetHandle(), &is_started); - const int error = conv_service_start(service_handle, channel->GetHandle(), nullptr); - if (CONV_ERROR_NONE != error) { - return LogAndCreateTizenError(AbortError, "conv_service_start [fail]"); - } + if (is_started) { + picojson::object param; + param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); + param[kChannel] = ConvergenceChannel::ToJson(channel->GetHandle()); + param[kServiceResultType] = picojson::value("onStart"); - opened_channels.push_back(ch_ptr.release()); + // totu + convergence_plugin_->ReplyAsync(kAppCommunicationListenerCallback, + cur_listener_id, true, param); + } else { + UpdateListener(cur_listener_id, REMOTE_SERVICE_START); + + const int error = conv_service_start(service_handle, channel->GetHandle(), nullptr); + if (CONV_ERROR_NONE != error) { + LoggerD("conv_service_start [fail] %d %s", error, get_error_message(error)); + return LogAndCreateTizenError(AbortError, "conv_service_start [fail]"); + } + + opened_channels.push_back(ch_ptr.release()); + } return TizenSuccess(); } @@ -371,14 +389,33 @@ common::TizenResult ConvergenceAppCommunicationServerService::Start( return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); } - UpdateListener(cur_listener_id, LOCAL_SERVICE_START); - const int error = conv_service_start(service_handle, channel->GetHandle(), nullptr); - if (CONV_ERROR_NONE != error) { - return LogAndCreateTizenError(AbortError, "conv_service_start [fail]"); - } + 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_handle, channel->GetHandle(), &is_started); + + if (is_started) { + picojson::object param; + param[kServiceListenerStatus] = picojson::value(kServiceListenerStatusOk); + param[kChannel] = ConvergenceChannel::ToJson(channel->GetHandle()); + param[kServiceResultType] = picojson::value("onStart"); - opened_channels.push_back(ch_ptr.release()); + // totu + convergence_plugin_->ReplyAsync(kAppCommunicationListenerCallback, + cur_listener_id, true, param); + } else { + UpdateListener(cur_listener_id, LOCAL_SERVICE_START); + + const int error = conv_service_start(service_handle, channel->GetHandle(), nullptr); + if (CONV_ERROR_NONE != error) { + LoggerD("conv_service_start [fail] %d %s", error, get_error_message(error)); + return LogAndCreateTizenError(AbortError, "conv_service_start [fail]"); + } + + opened_channels.push_back(ch_ptr.release()); + } return TizenSuccess(); }