[Content] Playlist tct fixes
authorWojciech Kosowicz <w.kosowicz@samsung.com>
Mon, 23 Mar 2015 10:05:02 +0000 (11:05 +0100)
committerRafal Galka <r.galka@samsung.com>
Mon, 23 Mar 2015 15:36:11 +0000 (00:36 +0900)
[Verification] 225/230 tct tests passed

Change-Id: I5384aa9f70dc22b4ed6800de18e4b9805fae9715
Signed-off-by: Wojciech Kosowicz <w.kosowicz@samsung.com>
src/content/content_instance.cc
src/content/content_manager.cc
src/content/js/datatypes.js
src/content/js/playlist.js

index 115bc329d3aa43cd56e8c4bcd5bcada9877f20ff..3e251e864702dc190e57b73839d2f6b2321ad175 100755 (executable)
@@ -146,8 +146,8 @@ static void* WorkThread(const std::shared_ptr<ReplyCallbackData>& user_data) {
       //ContentManagerPlaylistSetOrderCallback
     }
     case ContentManagerPlaylistMoveCallback: {
-      std::string playlist_id = user_data->args.get("playlist_id").get<std::string>();
-      double member_id = user_data->args.get("member_id").get<double>();
+      std::string playlist_id = user_data->args.get("playlistId").get<std::string>();
+      double member_id = user_data->args.get("memberId").get<double>();
       double delta = user_data->args.get("delta").get<double>();
       ContentManager::getInstance()->playlistMove(user_data);
       break;
@@ -446,8 +446,8 @@ void ContentInstance::ContentManagerPlaylistGet(const picojson::value& args, pic
 void ContentInstance::ContentManagerPlaylistRemove(const picojson::value& args, picojson::object& out) {
   int ret;
   if(ContentManager::getInstance()->isConnected()) {
-    std::string playlist_id = args.get("playlist_id").get<std::string>();
-    int member_id = args.get("member_id").get<double>();
+    std::string playlist_id = args.get("playlistId").get<std::string>();
+    int member_id = args.get("memberId").get<double>();
     ret = ContentManager::getInstance()->playlistRemove(playlist_id, member_id);
     if(ret != MEDIA_CONTENT_ERROR_NONE) {
       ReportError(ContentManager::getInstance()->convertError(ret),out);
index 954c90108fa5968a9fece8e0c650d69fd70ba5d4..26178737ff2e1dd9ff5464ed89022e208097597b 100755 (executable)
@@ -904,6 +904,8 @@ void ContentManager::playlistGet(const std::shared_ptr<ReplyCallbackData>& user_
 
   int ret = MEDIA_CONTENT_ERROR_NONE;
   media_playlist_h playlist = NULL;
+  media_content_order_e order = MEDIA_CONTENT_ORDER_ASC;
+  const std::string playOrder("play_order");
 
   std::string playlist_id = user_data->args.get("playlistId").get<std::string>();
   ret = media_playlist_get_playlist_from_db(std::stoi(playlist_id), &playlist);
@@ -929,6 +931,11 @@ void ContentManager::playlistGet(const std::shared_ptr<ReplyCallbackData>& user_
   if (ret != MEDIA_CONTENT_ERROR_NONE) {
     LoggerD("Setting a offset/count is failed.");
   }
+  ret = media_filter_set_order(filter, order, playOrder.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT);
+  if (ret != MEDIA_CONTENT_ERROR_NONE) {
+    LoggerD("Setting a offset/count is failed.");
+  }
+
   picojson::value::array arrayContent;
   ret = media_playlist_foreach_media_from_db(std::stoi(playlist_id),
     filter, playlist_content_member_cb, static_cast<void*>(&arrayContent));
@@ -950,7 +957,7 @@ void ContentManager::playlistRemovebatch(const std::shared_ptr<ReplyCallbackData
   int ret = MEDIA_CONTENT_ERROR_NONE;
   media_playlist_h playlist = NULL;
 
-  std::string playlist_id = user_data->args.get("playlist_id").get<std::string>();
+  std::string playlist_id = user_data->args.get("playlistId").get<std::string>();
   ret = media_playlist_get_playlist_from_db(std::stoi(playlist_id), &playlist);
   if(ret != MEDIA_CONTENT_ERROR_NONE && playlist == NULL) {
     UnknownException err("Getting playlist is failed.");
@@ -985,7 +992,7 @@ void ContentManager::playlistSetOrder(const std::shared_ptr<ReplyCallbackData>&
   int ret = MEDIA_CONTENT_ERROR_NONE;
   media_playlist_h playlist = NULL;
 
-  std::string playlist_id = user_data->args.get("playlist_id").get<std::string>();
+  std::string playlist_id = user_data->args.get("playlistId").get<std::string>();
   ret = media_playlist_get_playlist_from_db(std::stoi(playlist_id), &playlist);
   if(ret != MEDIA_CONTENT_ERROR_NONE && playlist == NULL) {
     UnknownException err("Getting playlist is failed.");
@@ -1028,7 +1035,7 @@ void ContentManager::playlistSetOrder(const std::shared_ptr<ReplyCallbackData>&
 void ContentManager::playlistMove(const std::shared_ptr<ReplyCallbackData>& user_data) {
   int ret = MEDIA_CONTENT_ERROR_NONE;
   media_playlist_h playlist = NULL;
-  std::string playlist_id = user_data->args.get("playlist_id").get<std::string>();
+  std::string playlist_id = user_data->args.get("playlistId").get<std::string>();
   ret = media_playlist_get_playlist_from_db(std::stoi(playlist_id), &playlist);
   if(ret != MEDIA_CONTENT_ERROR_NONE && playlist == NULL) {
     UnknownException err("Getting playlist is failed.");
@@ -1037,7 +1044,7 @@ void ContentManager::playlistMove(const std::shared_ptr<ReplyCallbackData>& user
     return;
   }
   int old_order;
-  double member_id = user_data->args.get("member_id").get<double>();
+  double member_id = user_data->args.get("memberId").get<double>();
   double delta = user_data->args.get("delta").get<double>();
   ret = media_playlist_get_play_order(playlist, static_cast<int>(member_id), &old_order);
   if (ret != MEDIA_CONTENT_ERROR_NONE) {
index 11b7cd193202501df952e160108eee59623e6024..11d3da5a888dc7d9a40bc7df926ab81ec5658b2d 100644 (file)
@@ -677,7 +677,7 @@ ImageContent.prototype.constructor = ImageContent;
 
 
 function PlaylistItem(data) {
-    var content;
+  var content = data;
 
   Object.defineProperties(this, {
     content: {
@@ -685,22 +685,11 @@ function PlaylistItem(data) {
         return content;
       },
       set: function(v) {
-        if (v instanceof Content ) {
+        if (edit_.isAllowed && v instanceof Content ) {
           content = v;
         }
       },
       enumerable: true
     }
   });
-
-  if (type_.isObject(data)) {
-    // fill object with data
-    edit_.allow();
-    for (var key in data) {
-      if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
-        this[key] = data[key];
-      }
-    }
-    edit_.disallow();
-  }
 }
index f10c8a2b9ee4dcfab46226be5a1c94ee24d38f66..6e5aeeb793677d162b68783aa5875bbbc3693f46 100644 (file)
@@ -116,10 +116,10 @@ Playlist.prototype.remove = function (item) {
   ]);
 
   var data = {
-    item: args.item
+    playlistId: this.id,
+    memberId: args.item.content.memberId
   };
-
-  var result = native_.callSync('Playlist_remove', data);
+  var result = native_.callSync('ContentPlaylist_remove', data);
 
   if (native_.isFailure(result)) {
     throw native_.getErrorObject(result);
@@ -128,13 +128,19 @@ Playlist.prototype.remove = function (item) {
 
 Playlist.prototype.removeBatch = function (items, successCallback, errorCallback) {
   var args = validator_.validateArgs(arguments, [
-    {name: 'items', type: types_.PLATFORM_OBJECT, values: PlaylistItem},
+    {name: 'items', type: types_.ARRAY, values: PlaylistItem},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
   ]);
 
+  var members = [];
+  for (var i = 0; i < args.items.length; i++) {
+    members.push(args.items[i].content.memberId);
+  }
+
   var data = {
-    items: args.items
+    playlistId: this.id,
+    members: members
   };
 
   var callback = function (result) {
@@ -145,7 +151,7 @@ Playlist.prototype.removeBatch = function (items, successCallback, errorCallback
     native_.callIfPossible(args.successCallback);
   };
 
-  native_.call('Playlist_removeBatch', data, callback);
+  native_.call('ContentPlaylist_removeBatch', data, callback);
 };
 
 Playlist.prototype.get = function (successCallback, errorCallback, count, offset) {
@@ -170,7 +176,9 @@ Playlist.prototype.get = function (successCallback, errorCallback, count, offset
     result = native_.getResultObject(result);
     var out = [];
     for (var i = 0, max = result.length; i < max; i++) {
-      out.push(new PlaylistItem(createContentObject_(result[i])));
+      var itemToPush = createContentObject_(result[i]);
+      itemToPush['memberId'] = result[i]['playlist_member_id'];
+      out.push(new PlaylistItem(itemToPush));
     }
     native_.callIfPossible(args.successCallback, out);
   };
@@ -180,13 +188,19 @@ Playlist.prototype.get = function (successCallback, errorCallback, count, offset
 
 Playlist.prototype.setOrder = function (items, successCallback, errorCallback) {
   var args = validator_.validateArgs(arguments, [
-    {name: 'items', type: types_.PLATFORM_OBJECT, values: PlaylistItem},
+    {name: 'items', type: types_.ARRAY, values: PlaylistItem},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
   ]);
 
+  var members = [];
+  for (var i = 0; i < args.items.length; i++) {
+    members.push(args.items[i].content.memberId);
+  }
+
   var data = {
-    items: args.items
+    playlistId: this.id,
+    members: members,
   };
 
   var callback = function (result) {
@@ -197,19 +211,20 @@ Playlist.prototype.setOrder = function (items, successCallback, errorCallback) {
     native_.callIfPossible(args.successCallback);
   };
 
-  native_.call('Playlist_setOrder', data, callback);
+  native_.call('ContentPlaylist_setOrder', data, callback);
 };
 
 Playlist.prototype.move = function (item, delta, successCallback, errorCallback) {
   var args = validator_.validateArgs(arguments, [
-    {name: 'item', type: types_.PLATFORM_OBJECT, values: tizen.PlaylistItem},
+    {name: 'item', type: types_.PLATFORM_OBJECT, values: PlaylistItem},
     {name: 'delta', type: types_.LONG},
     {name: 'successCallback', type: types_.FUNCTION, optional: true, nullable: true},
     {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true}
   ]);
 
   var data = {
-    item: args.item,
+    playlistId: this.id,
+    memberId: args.item.content.memberId,
     delta: args.delta
   };
 
@@ -220,6 +235,5 @@ Playlist.prototype.move = function (item, delta, successCallback, errorCallback)
     }
     native_.callIfPossible(args.successCallback);
   };
-
-  native_.call('Playlist_move', data, callback);
+  native_.call('ContentPlaylist_move', data, callback);
 };