From: Piotr Kosko Date: Thu, 1 Dec 2016 11:19:11 +0000 (+0100) Subject: [Convergence] Reporting error while disconnect fails X-Git-Tag: submit/tizen/20161206.092612^2~2^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e63ac5796ac957c07b6445577b053dca2fb1617;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Convergence] Reporting error while disconnect fails Change-Id: I0c75536ffa79d89f1fd999646256195a5b33000c Signed-off-by: Piotr Kosko --- diff --git a/src/convergence/convergence_api.js b/src/convergence/convergence_api.js index 9e362c5e..615b81cc 100644 --- a/src/convergence/convergence_api.js +++ b/src/convergence/convergence_api.js @@ -421,21 +421,21 @@ RemoteAppControlService.prototype.disconnect = function(successCallback, errorCa throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.'); } + var that = this; var result = native_.call('RemoteAppControlService_disconnect', { deviceId: this._deviceId }, function(result) { if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); + } else { + updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, that); + native_.callIfPossible(successCallback, that); } }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); - } else { - updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this); } - - native_.callIfPossible(successCallback, this); }; RemoteAppControlService.prototype.start = function() { @@ -1054,20 +1054,20 @@ AppCommunicationClientService.prototype.disconnect = function(successCallback, e if (this.connectionState != ConnectionState.CONNECTED) throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'Service is not connected yet.'); + var that = this; var result = native_.call('AppCommunicationClientService_disconnect', { deviceId: this._deviceId }, function(result) { if (native_.isFailure(result)) { native_.callIfPossible(errorCallback, native_.getErrorObject(result)); } else { - native_.callIfPossible(successCallback, this); + updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, that); + native_.callIfPossible(successCallback, that); } }); if (native_.isFailure(result)) { throw native_.getErrorObject(result); - } else { - updateWithInternalData({ connectionState: ConnectionState.NOT_CONNECTED }, this); } }; diff --git a/src/convergence/convergence_app_communication_service.cc b/src/convergence/convergence_app_communication_service.cc index 42ce200f..4272e4ee 100644 --- a/src/convergence/convergence_app_communication_service.cc +++ b/src/convergence/convergence_app_communication_service.cc @@ -467,14 +467,27 @@ common::TizenResult ConvergenceAppCommunicationClientService::Disconnect() { if (!service) return LogAndCreateTizenError(AbortError, "Service is NULL"); - const int error = conv_service_disconnect(service); + int error = conv_service_disconnect(service); if (CONV_ERROR_NONE != error) { - // TODO: Handle error trace_conv_error(error, __LINE__, "conv_service_disconnect"); return LogAndCreateTizenError(AbortError, "conv_service_disconnect [fail]"); } - return TizenSuccess(); + conv_service_connection_state_e state = CONV_SERVICE_CONNECTION_STATE_NONE; + error = conv_service_get_connection_state(service, &state); + if (CONV_ERROR_NONE != error) { + LoggerE("Error gathering state [%d] : %s", error, get_error_message(error)); + return LogAndCreateTizenError(AbortError, "Error gathering state"); + } else { + LoggerD("state: %d" , state); + + } + if (CONV_SERVICE_CONNECTION_STATE_NOT_CONNECTED == state) { + return TizenSuccess(); + } else { + LoggerE("Service is still connected, reporting error"); + return LogAndCreateTizenError(AbortError, "Disconnecting failed."); + } } diff --git a/src/convergence/convergence_remote_app_control_service.cc b/src/convergence/convergence_remote_app_control_service.cc index 201b26d8..bd9612b5 100644 --- a/src/convergence/convergence_remote_app_control_service.cc +++ b/src/convergence/convergence_remote_app_control_service.cc @@ -123,7 +123,7 @@ TizenResult ConvergenceRemoteAppControlService::Disconnect() { return LogAndCreateTizenError(AbortError, "Service with specified type does not exist"); } - const int error = conv_service_disconnect(service); + int error = conv_service_disconnect(service); if (CONV_ERROR_NONE != error) { return LogAndCreateTizenError(AbortError, "conv_service_disconnect [Fail]"); } else { @@ -132,7 +132,21 @@ TizenResult ConvergenceRemoteAppControlService::Disconnect() { LoggerI("Disconnected from the remote service"); } - return TizenSuccess(); + conv_service_connection_state_e state = CONV_SERVICE_CONNECTION_STATE_NONE; + error = conv_service_get_connection_state(service, &state); + if (CONV_ERROR_NONE != error) { + LoggerE("Error gathering state [%d] : %s", error, get_error_message(error)); + return LogAndCreateTizenError(AbortError, "Error gathering state"); + } else { + LoggerD("state: %d" , state); + + } + if (CONV_SERVICE_CONNECTION_STATE_NOT_CONNECTED == state) { + return TizenSuccess(); + } else { + LoggerE("Service is still connected, reporting error"); + return LogAndCreateTizenError(AbortError, "Disconnecting failed."); + } } TizenResult ConvergenceRemoteAppControlService::Start(const bool reply, const int cur_listener_id) {