[VoiceControl] Fixing bug with releasing listeners 18/170518/2
authorRafal Walczyna <r.walczyna@partner.samsung.com>
Tue, 20 Feb 2018 11:37:53 +0000 (12:37 +0100)
committerRafal Walczyna <r.walczyna@partner.samsung.com>
Tue, 20 Feb 2018 11:49:50 +0000 (12:49 +0100)
Listeners was not removed after calling release() function

[verification] 100% passrate (auto and manual) on TM1

Change-Id: Ie241a7df83a72d0756f51d61b507f60d8b7c5f0f
Signed-off-by: Rafal Walczyna <r.walczyna@partner.samsung.com>
src/voicecontrol/voicecontrol_api.js
src/voicecontrol/voicecontrol_client.cc
src/voicecontrol/voicecontrol_instance.cc
src/voicecontrol/voicecontrol_util.cc

index 5caa4a4..6a588bf 100755 (executable)
@@ -66,6 +66,12 @@ ListenerManager.prototype.removeListener = function (watchId, nativeCall) {
   }
 };
 
+ListenerManager.prototype.removeAllListeners = function () {
+  this.native.removeListener(this.listenerName);
+  this.listeners = {};
+  this.nativeSet = false;
+};
+
 var VcResultListener = new ListenerManager(native_, 'onresult', function(result, listener) {
   listener(result.event, result.list, result.results);
 });
@@ -193,6 +199,8 @@ VoiceControlClient.prototype.release = function () {
   if (native_.isFailure(result)) {
     throw native_.getErrorObject(result);
   }
+  VcLangListener.removeAllListeners();
+  VcResultListener.removeAllListeners();
 };
 
 // Constructor of VoiceControlCommand
index debba64..e70976b 100644 (file)
@@ -31,9 +31,11 @@ namespace extension {
 namespace voicecontrol {
 
 VoiceControlClient::VoiceControlClient() : is_result_cb_set(false), is_lang_cb_set(false) {
+  ScopeLogger();
 }
 
 VoiceControlClient::~VoiceControlClient() {
+  ScopeLogger();
 }
 
 common::PlatformResult VoiceControlClient::GetCurrentLanguage(std::string* language) {
index 7a11ceb..8e59714 100644 (file)
@@ -40,6 +40,7 @@ using namespace common;
 using namespace extension::voicecontrol;
 
 VoiceControlInstance::VoiceControlInstance() : voice_control_client() {
+  ScopeLogger();
   using namespace std::placeholders;
 #define REGISTER_SYNC(c, x) \
   RegisterSyncHandler(c, std::bind(&VoiceControlInstance::x, this, _1, _2));
@@ -56,6 +57,7 @@ VoiceControlInstance::VoiceControlInstance() : voice_control_client() {
 }
 
 VoiceControlInstance::~VoiceControlInstance() {
+  ScopeLogger();
   int ret = VC_ERROR_NONE;
   ret = vc_deinitialize();
   if (VC_ERROR_NONE != ret && VC_ERROR_INVALID_STATE != ret) {
index f54c1da..d244e21 100644 (file)
@@ -21,6 +21,7 @@ namespace extension {
 namespace voicecontrol {
 
 const std::string& MakeErrorMessage(const int ret) {
+  ScopeLogger();
   switch (ret) {
     case VC_ERROR_NONE:
       return NO_ERROR;
@@ -41,6 +42,7 @@ const std::string& MakeErrorMessage(const int ret) {
 }
 
 common::PlatformResult MakeErrorObject(const int ret) {
+  ScopeLogger();
   std::string message = MakeErrorMessage(ret);
   switch (ret) {
     case VC_ERROR_NONE:
@@ -57,6 +59,7 @@ common::PlatformResult MakeErrorObject(const int ret) {
 }
 
 int VcConvertCmdType(const std::string& type) {
+  ScopeLogger("%s", type.c_str());
   // TODO add switch here when also other types of command will be also supported.
   // For now, only foreground is supported, we return it as the default value.
   return VC_COMMAND_TYPE_FOREGROUND;