Merge "[MediaController] Adding, updating and sending item." into tizen
authorPiotr Kosko <p.kosko@samsung.com>
Thu, 25 Apr 2019 08:33:23 +0000 (08:33 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 25 Apr 2019 08:33:23 +0000 (08:33 +0000)
packaging/webapi-plugins.spec
src/content/content_filter.cc
src/content/js/common.js
src/content/js/datatypes.js
src/filesystem/filesystem_manager.cc
src/filesystem/filesystem_utils.cc
src/mediacontroller/mediacontroller_client.cc

index 39fac46..8614f0b 100644 (file)
@@ -8,7 +8,7 @@
 %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions}
 
 Name:       webapi-plugins
-Version:    2.42
+Version:    2.43
 Release:    0
 License:    Apache-2.0 and BSD-3-Clause and MIT
 Group:      Development/Libraries
index cb69310..4d3bfb9 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "common/converter.h"
 #include "common/logger.h"
+#include "common/tools.h"
 
 using common::AttributeMatchFlag;
 using common::CompositeFilterType;
@@ -84,6 +85,10 @@ PlatformResult ContentFilter::MapField(const std::string& name, std::string* res
   ScopeLogger();
   auto it = attributeNameMap.find(name);
   if (it != attributeNameMap.end()) {
+    if (name == "rating" || name == "description") {
+      std::string warning = "Filtering by attribute '" + name + "'";
+      common::tools::PrintDeprecationWarningFor(warning.c_str());
+    }
     *result = it->second;
   } else {
     return LogAndCreateResult(ErrorCode::INVALID_VALUES_ERR);
index e60816b..99d9258 100755 (executable)
@@ -21,6 +21,8 @@ var validator_ = utils_.validator;
 var types_ = validator_.Types;
 var native_ = new xwalk.utils.NativeManager(extension);
 
+var isEarlierThan55 = utils_.isAppVersionEarlierThan('5.5');
+
 var EditManager = function() {
   this.isAllowed = false;
 };
index 60b95cc..27863f6 100755 (executable)
@@ -122,7 +122,15 @@ function ContentDirectory(data) {
 
 
 function Content(data) {
-  var editableAttributes = ['name', 'rating', 'description'];
+  var editableAttributes = ['isFavorite'];
+  // since 5.5 these attributes are readonly, it is disallowed to modify them,
+  // but for applications developed for earlier versions backward compatibility
+  // is kept
+  if (isEarlierThan55) {
+    editableAttributes.push('name');
+    editableAttributes.push('rating');
+    editableAttributes.push('description');
+  }
   var id;
   var name;
   var type;
@@ -159,8 +167,15 @@ function Content(data) {
         return name;
       },
       set: function(v) {
-        if (!type_.isNull(v)) {
-          name = converter_.toString(v, false);
+        // since 5.5 this attribute is readonly, it is disallowed to modify it,
+        // but for applications developed for earlier versions backward compatibility
+        // is kept
+        if (isEarlierThan55 || edit_.isAllowed) {
+          if (!type_.isNull(v)) {
+            name = converter_.toString(v, false);
+          }
+        } else {
+          utils_.warn('Since 5.5 "name" attribute is readonly, modifying it has no effect.');
         }
       },
       enumerable: true
@@ -258,7 +273,14 @@ function Content(data) {
         return description;
       },
       set: function(v) {
-        description = converter_.toString(v, true);
+        // since 5.5 this attribute is readonly, it is disallowed to modify it,
+        // but for applications developed for earlier versions backward compatibility
+        // is kept
+        if (isEarlierThan55 || edit_.isAllowed) {
+          description = converter_.toString(v, true);
+        } else {
+          utils_.warn('Since 5.5 "description" attribute is readonly, modifying it has no effect.');
+        }
       },
       enumerable: true
     },
@@ -267,8 +289,15 @@ function Content(data) {
         return rating;
       },
       set: function(v) {
-        if (!type_.isNull(v) && v >= 0 && v <= 10) {
-          rating = converter_.toUnsignedLong(v, false);
+        // since 5.5 this attribute is readonly, it is disallowed to modify it,
+        // but for applications developed for earlier versions backward compatibility
+        // is kept
+        if (isEarlierThan55 || edit_.isAllowed) {
+          if (!type_.isNull(v) && v >= 0 && v <= 10) {
+            rating = converter_.toUnsignedLong(v, false);
+          }
+        } else {
+          utils_.warn('Since 5.5 "rating" attribute is readonly, modifying it has no effect.');
         }
       },
       enumerable: true
@@ -303,7 +332,12 @@ function VideoContent(data) {
   Content.call(this, data);
 
   var editableAttributes = this.editableAttributes;
-  editableAttributes.push('geolocation');
+  // since 5.5 this attribute is readonly, it is disallowed to modify it,
+  // but for applications developed for earlier versions backward compatibility
+  // is kept
+  if (isEarlierThan55) {
+    editableAttributes.push('geolocation');
+  }
 
   var geolocation;
   var album;
@@ -323,10 +357,17 @@ function VideoContent(data) {
         return geolocation;
       },
       set: function(v) {
-        if (!type_.isNull(v)) {
-          var latitude = converter_.toDouble(v.latitude, false);
-          var longitude = converter_.toDouble(v.longitude, false);
-          geolocation = new tizen.SimpleCoordinates(latitude, longitude);
+        // since 5.5 this attribute is readonly, it is disallowed to modify it,
+        // but for applications developed for earlier versions backward compatibility
+        // is kept
+        if (isEarlierThan55 || edit_.isAllowed) {
+          if (!type_.isNull(v)) {
+            var latitude = converter_.toDouble(v.latitude, false);
+            var longitude = converter_.toDouble(v.longitude, false);
+            geolocation = new tizen.SimpleCoordinates(latitude, longitude);
+          }
+        } else {
+          utils_.warn('Since 5.5 "geolocation" attribute is readonly, modifying it has no effect.');
         }
       },
       enumerable: true
@@ -615,8 +656,13 @@ function ImageContent(data) {
   Content.call(this, data);
 
   var editableAttributes = this.editableAttributes;
-  editableAttributes.push('geolocation');
-  editableAttributes.push('orientation');
+  // since 5.5 these attributes are readonly, it is disallowed to modify them,
+  // but for applications developed for earlier versions backward compatibility
+  // is kept
+  if (isEarlierThan55) {
+    editableAttributes.push('geolocation');
+    editableAttributes.push('orientation');
+  }
 
   var geolocation;
   var width;
@@ -634,10 +680,17 @@ function ImageContent(data) {
         return geolocation;
       },
       set: function(v) {
-        if (!type_.isNull(v)) {
-          var latitude = converter_.toDouble(v.latitude, false);
-          var longitude = converter_.toDouble(v.longitude, false);
-          geolocation = new tizen.SimpleCoordinates(latitude, longitude);
+        // since 5.5 this attribute is readonly, it is disallowed to modify it,
+        // but for applications developed for earlier versions backward compatibility
+        // is kept
+        if (isEarlierThan55 || edit_.isAllowed) {
+          if (!type_.isNull(v)) {
+            var latitude = converter_.toDouble(v.latitude, false);
+            var longitude = converter_.toDouble(v.longitude, false);
+            geolocation = new tizen.SimpleCoordinates(latitude, longitude);
+          }
+        } else {
+          utils_.warn('Since 5.5 "geolocation" attribute is readonly, modifying it has no effect.');
         }
       },
       enumerable: true
@@ -669,8 +722,15 @@ function ImageContent(data) {
         return orientation;
       },
       set: function(v) {
-        if (!type_.isNull(v)) {
-          orientation = converter_.toEnum(v, Object.keys(ImageContentOrientation), false);
+        // since 5.5 this attribute is readonly, it is disallowed to modify it,
+        // but for applications developed for earlier versions backward compatibility
+        // is kept
+        if (isEarlierThan55 || edit_.isAllowed) {
+          if (!type_.isNull(v)) {
+            orientation = converter_.toEnum(v, Object.keys(ImageContentOrientation), false);
+          }
+        } else {
+          utils_.warn('Since 5.5 "orientation" attribute is readonly, modifying it has no effect.');
         }
       },
       enumerable: true
index 8ca885d..9c8a49e 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include "filesystem/filesystem_manager.h"
-
 #include <app_manager.h>
 #include <dirent.h>
 #include <fcntl.h>
@@ -99,13 +98,29 @@ FilesystemError copyDirectory(const std::string& originPath, const std::string&
   SCOPE_EXIT {
     (void)closedir(dp);
   };
-  errno = 0;
-  struct dirent* entry = nullptr;
-  while (nullptr != (entry = readdir(dp))) {
-    if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) continue;
+
+  while (true) {
+    errno = 0;
+    struct dirent* entry = readdir(dp);
+    int readdir_errno = errno;
+    if (0 != readdir_errno) {
+      LoggerE("readdir() error message: %s", strerror(readdir_errno));
+      return FilesystemError::Other;
+    }
+
+    if (nullptr == entry) {
+        LoggerD("No more entries in the directory");
+        break;
+    }
+
+    if (std::strcmp(entry->d_name, ".") == 0 || std::strcmp(entry->d_name, "..") == 0) {
+      LoggerD("Skipping %s directory", entry->d_name);
+      continue;
+    }
 
     std::string oldLocation = originPath + std::string("/") + std::string(entry->d_name);
     std::string newLocation = destPath + std::string("/") + std::string(entry->d_name);
+
     FilesystemError fstatus = FilesystemError::None;
     if (entry->d_type == DT_DIR) {
       fstatus = copyDirectory(oldLocation, newLocation);
@@ -118,10 +133,6 @@ FilesystemError copyDirectory(const std::string& originPath, const std::string&
     }
   }
 
-  if (0 != errno) {
-    LoggerE("error occured");
-    return FilesystemError::Other;
-  }
   return FilesystemError::None;
 }
 
index 00b8c81..9c84011 100644 (file)
@@ -201,19 +201,26 @@ void ListDirectory(const std::string& path, std::function<void(const char*, unsi
       LoggerW("closedir failed");
     }
   });
-  errno = 0;
 
-  for (dirent* entry; (entry = ::readdir(d));) {
+  while (true) {
+    errno = 0;
+    dirent* entry = ::readdir(d);
+    int readdir_errno = errno;
+    if (0 != readdir_errno) {
+        throw std::system_error{
+            errno, std::generic_category(),
+            "Failed to read directory: "s + GetErrorString(readdir_errno)};
+    }
+
+    if (entry == nullptr) {
+        break;
+    }
+
     if (0 == std::strcmp(entry->d_name, ".") || 0 == std::strcmp(entry->d_name, "..")) {
       continue;
     }
     next(entry->d_name, entry->d_type);
   }
-
-  if (0 != errno) {
-    throw std::system_error{errno, std::generic_category(),
-                            "Failed to read directory: "s + GetErrorString(errno)};
-  }
 }
 
 void RemoveDirectoryRecursively(const std::string& path) {
index dfb4bbb..012a044 100644 (file)
@@ -514,7 +514,7 @@ PlatformResult MediaControllerClient::SendCommand(const std::string& server_name
   }
 
   ret =
-      mc_client_send_custom_cmd(handle_, server_name.c_str(), command.c_str(), bundle, &request_id);
+      mc_client_send_custom_cmd(handle_, server_name.c_str(), command.c_str(), bundle, request_id);
   if (MEDIA_CONTROLLER_ERROR_NONE != ret) {
     return LogAndCreateResult(
         ErrorCode::UNKNOWN_ERR, "Error sending custom command",