From: Wojciech Kosowicz Date: Mon, 23 Mar 2015 10:05:02 +0000 (+0100) Subject: [Content] Playlist tct fixes X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~258 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1b4adaa495939e6bc32e89b8a233ccd77c774e2f;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Content] Playlist tct fixes [Verification] 225/230 tct tests passed Change-Id: I5384aa9f70dc22b4ed6800de18e4b9805fae9715 Signed-off-by: Wojciech Kosowicz --- diff --git a/src/content/content_instance.cc b/src/content/content_instance.cc index 115bc329..3e251e86 100755 --- a/src/content/content_instance.cc +++ b/src/content/content_instance.cc @@ -146,8 +146,8 @@ static void* WorkThread(const std::shared_ptr& user_data) { //ContentManagerPlaylistSetOrderCallback } case ContentManagerPlaylistMoveCallback: { - std::string playlist_id = user_data->args.get("playlist_id").get(); - double member_id = user_data->args.get("member_id").get(); + std::string playlist_id = user_data->args.get("playlistId").get(); + double member_id = user_data->args.get("memberId").get(); double delta = user_data->args.get("delta").get(); 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(); - int member_id = args.get("member_id").get(); + std::string playlist_id = args.get("playlistId").get(); + int member_id = args.get("memberId").get(); ret = ContentManager::getInstance()->playlistRemove(playlist_id, member_id); if(ret != MEDIA_CONTENT_ERROR_NONE) { ReportError(ContentManager::getInstance()->convertError(ret),out); diff --git a/src/content/content_manager.cc b/src/content/content_manager.cc index 954c9010..26178737 100755 --- a/src/content/content_manager.cc +++ b/src/content/content_manager.cc @@ -904,6 +904,8 @@ void ContentManager::playlistGet(const std::shared_ptr& 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(); ret = media_playlist_get_playlist_from_db(std::stoi(playlist_id), &playlist); @@ -929,6 +931,11 @@ void ContentManager::playlistGet(const std::shared_ptr& 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(&arrayContent)); @@ -950,7 +957,7 @@ void ContentManager::playlistRemovebatch(const std::shared_ptrargs.get("playlist_id").get(); + std::string playlist_id = user_data->args.get("playlistId").get(); 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& int ret = MEDIA_CONTENT_ERROR_NONE; media_playlist_h playlist = NULL; - std::string playlist_id = user_data->args.get("playlist_id").get(); + std::string playlist_id = user_data->args.get("playlistId").get(); 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& void ContentManager::playlistMove(const std::shared_ptr& 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 playlist_id = user_data->args.get("playlistId").get(); 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& user return; } int old_order; - double member_id = user_data->args.get("member_id").get(); + double member_id = user_data->args.get("memberId").get(); double delta = user_data->args.get("delta").get(); ret = media_playlist_get_play_order(playlist, static_cast(member_id), &old_order); if (ret != MEDIA_CONTENT_ERROR_NONE) { diff --git a/src/content/js/datatypes.js b/src/content/js/datatypes.js index 11b7cd19..11d3da5a 100644 --- a/src/content/js/datatypes.js +++ b/src/content/js/datatypes.js @@ -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(); - } } diff --git a/src/content/js/playlist.js b/src/content/js/playlist.js index f10c8a2b..6e5aeeb7 100644 --- a/src/content/js/playlist.js +++ b/src/content/js/playlist.js @@ -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); };