[Content] additional check for registering listeners
authorPiotr Kosko <p.kosko@samsung.com>
Fri, 18 Sep 2015 10:46:51 +0000 (12:46 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Fri, 18 Sep 2015 11:17:14 +0000 (20:17 +0900)
[Feature] Additional check prevents multiple registering listener in native code.

[Verification] Code compiles without errors.
  Checked in chrome console.
  TCT passrate with corrected ContentChangeCallback_oncontentdirupdated test is 100%.

Change-Id: I78eb3526ae7a14e6f8f6bee57ffce677e600724e
Signed-off-by: Piotr Kosko <p.kosko@samsung.com>
src/content/content_manager.cc

index f06efa810bd3b73bea8de9219cd7f257c240616c..18d9f5c116aa57eea590588fa74088212cd24441 100755 (executable)
@@ -867,13 +867,13 @@ PlatformResult ContentManager::setV2ChangeListener(media_content_noti_h* noti_ha
                                                  media_content_db_update_cb callback,
                                                  void *user_data) {
   LoggerD("Enter");
-
-  int ret = media_content_set_db_updated_cb_v2(noti_handle, callback, user_data);
-  if(ret != MEDIA_CONTENT_ERROR_NONE) {
-    LoggerE("Failed: registering the listener of cb_v2 is failed");
-    return PlatformResult(ErrorCode::UNKNOWN_ERR, ("registering the listener is failed."));
+  if (nullptr == *noti_handle) {
+    int ret = media_content_set_db_updated_cb_v2(noti_handle, callback, user_data);
+    if(ret != MEDIA_CONTENT_ERROR_NONE) {
+      LoggerE("Failed: registering the listener of cb_v2 is failed");
+      return PlatformResult(ErrorCode::UNKNOWN_ERR, ("registering the listener is failed."));
+    }
   }
-
   return PlatformResult(ErrorCode::NO_ERROR);
 }