2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var privUtils_ = xwalk.utils;
26 var AudioContentLyricsType = {
27 SYNCHRONIZED: 'SYNCHRONIZED',
28 UNSYNCHRONIZED: 'UNSYNCHRONIZED'
31 var ImageContentOrientation = {
33 FLIP_HORIZONTAL: 'FLIP_HORIZONTAL',
34 ROTATE_180: 'ROTATE_180',
35 FLIP_VERTICAL: 'FLIP_VERTICAL',
36 TRANSPOSE: 'TRANSPOSE',
37 ROTATE_90: 'ROTATE_90',
38 TRANSVERSE: 'TRANSVERSE',
39 ROTATE_270: 'ROTATE_270'
42 function ContentDirectory(data) {
46 var modifiedDate = null;
48 Object.defineProperties(this, {
54 if (edit_.isAllowed) {
55 id = converter_.toString(v, false);
65 if (edit_.isAllowed) {
66 directoryURI = convertPathToUri_(converter_.toString(v, false));
76 if (edit_.isAllowed) {
77 title = converter_.toString(v, false);
84 utils_.printDeprecationWarningFor('ContentDirectoryStorageType');
85 return "storageType_NOT_SUPPORTED";
96 if (edit_.isAllowed) {
97 modifiedDate = v > 0 ? new Date(v * 1000) : null;
104 if (type_.isObject(data)) {
105 // fill object with data
107 for (var key in data) {
108 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
109 this[key] = data[key];
116 function Content(data) {
117 var editableAttributes = ['isFavorite'];
124 var thumbnailURIs = null;
125 var releaseDate = null;
126 var modifiedDate = null;
128 var description = null;
132 Object.defineProperties(this, {
133 editableAttributes: {
135 privUtils_.deprecationWarn(
136 'editableAttributes is deprecated since Tizen 9.0 with no replacement.',
139 return editableAttributes;
141 set: function () { },
149 if (edit_.isAllowed) {
150 id = converter_.toString(v, false);
160 // since 5.5 this attribute is readonly, it is disallowed to modify it
161 if (edit_.isAllowed) {
162 if (!type_.isNull(v)) {
163 name = converter_.toString(v, false);
167 'Since 5.5 "name" attribute is readonly, modifying it has no ' +
179 if (edit_.isAllowed) {
180 type = converter_.toEnum(v, Object.keys(ContentType), false);
190 if (edit_.isAllowed) {
191 mimeType = converter_.toString(v, false);
201 if (edit_.isAllowed) {
202 title = converter_.toString(v, false);
212 if (edit_.isAllowed) {
213 contentURI = convertPathToUri_(v);
220 return thumbnailURIs;
223 if (edit_.isAllowed) {
224 thumbnailURIs = converter_.toArray(v, true);
231 privUtils_.deprecationWarn(
232 'releaseDate is deprecated since Tizen 9.0 with no replacement.',
238 if (edit_.isAllowed) {
239 releaseDate = v > 0 ? new Date(v * 1000) : null;
249 if (edit_.isAllowed) {
250 modifiedDate = v > 0 ? new Date(v * 1000) : null;
260 if (edit_.isAllowed) {
261 size = converter_.toUnsignedLong(v, false);
268 privUtils_.deprecationWarn(
269 'description is deprecated since Tizen 9.0 with no replacement.',
275 // since 5.5 this attribute is readonly, it is disallowed to modify it
276 if (edit_.isAllowed) {
277 description = converter_.toString(v, true);
280 'Since 5.5 "description" attribute is readonly, modifying it ' +
289 privUtils_.deprecationWarn(
290 'rating is deprecated since Tizen 9.0 with no replacement.',
296 // since 5.5 this attribute is readonly, it is disallowed to modify it
297 if (edit_.isAllowed) {
298 if (!type_.isNull(v) && v >= 0 && v <= 10) {
299 rating = converter_.toUnsignedLong(v, false);
303 'Since 5.5 "rating" attribute is readonly, modifying it has no ' +
312 privUtils_.deprecationWarn(
313 'isFavorite is deprecated since Tizen 9.0 with no replacement.',
319 privUtils_.deprecationWarn(
320 'isFavorite is deprecated since Tizen 9.0 with no replacement.',
323 if (!type_.isNull(v)) {
324 isFavorite = converter_.toBoolean(v, false);
331 if (type_.isObject(data)) {
332 // fill object with data
334 for (var key in data) {
335 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
336 this[key] = data[key];
343 function VideoContent(data) {
344 Content.call(this, data);
346 var editableAttributes = this.editableAttributes;
354 Object.defineProperties(this, {
355 editableAttributes: {
357 privUtils_.deprecationWarn(
358 'editableAttributes is deprecated since Tizen 9.0 with no replacement.',
361 return editableAttributes;
363 set: function () { },
368 privUtils_.deprecationWarn(
369 'geolocation is deprecated since Tizen 9.0 with no replacement.',
372 // for keep geolocation's latitude and longitude readonly
373 // we need to return copy of this object
374 return new tizen.SimpleCoordinates(
375 geolocation.latitude,
376 geolocation.longitude
380 // since 5.5 this attribute is readonly, it is disallowed to modify it
381 if (edit_.isAllowed) {
382 if (!type_.isNull(v)) {
383 var latitude = converter_.toDouble(v.latitude, false);
384 var longitude = converter_.toDouble(v.longitude, false);
385 geolocation = new tizen.SimpleCoordinates(latitude, longitude);
389 'Since 5.5 "geolocation" attribute is readonly, modifying it ' +
398 privUtils_.deprecationWarn(
399 'album is deprecated since Tizen 9.0 with no replacement.',
405 if (edit_.isAllowed) {
406 album = converter_.toString(v, false);
413 privUtils_.deprecationWarn(
414 'artists is deprecated since Tizen 9.0 with no replacement.',
420 if (edit_.isAllowed) {
421 artists = converter_.toArray(v, true);
428 privUtils_.deprecationWarn(
429 'duration is deprecated since Tizen 9.0 with no replacement.',
435 if (edit_.isAllowed) {
436 duration = converter_.toUnsignedLong(v, false);
443 privUtils_.deprecationWarn(
444 'width is deprecated since Tizen 9.0 with no replacement.',
450 if (edit_.isAllowed) {
451 width = converter_.toUnsignedLong(v, false);
458 privUtils_.deprecationWarn(
459 'height is deprecated since Tizen 9.0 with no replacement.',
465 if (edit_.isAllowed) {
466 height = converter_.toUnsignedLong(v, false);
473 if (type_.isObject(data)) {
474 // fill object with data
476 for (var key in data) {
477 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
478 this[key] = data[key];
485 VideoContent.prototype = new Content();
486 VideoContent.prototype.constructor = VideoContent;
488 function AudioContentLyrics(data) {
493 Object.defineProperties(this, {
499 if (edit_.isAllowed) {
500 type = converter_.toEnum(
502 Object.keys(AudioContentLyricsType),
514 if (edit_.isAllowed) {
515 timestamps = converter_.toArray(v, true);
525 if (edit_.isAllowed) {
526 texts = converter_.toArray(v, false);
533 if (type_.isObject(data)) {
534 // fill object with data
536 for (var key in data) {
537 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
538 this[key] = data[key];
545 function AudioContent(data) {
546 Content.call(this, data);
558 var getLyrics = function() {
560 contentURI: convertUriToPath_(this.contentURI)
563 var result = native_.callSync('ContentManagerAudioGetLyrics', data);
565 if (native_.isFailure(result)) {
566 utils_.log('Getting lyrics failed for ' + data.contentURI);
567 var error_object = native_.getErrorObject(result);
568 if (WebAPIException.SECURITY_ERR == error_object.code) {
574 return new AudioContentLyrics(native_.getResultObject(result));
577 Object.defineProperties(this, {
583 if (edit_.isAllowed) {
584 album = converter_.toString(v, false);
594 if (edit_.isAllowed) {
595 genres = converter_.toArray(v, true);
605 if (edit_.isAllowed) {
606 artists = converter_.toArray(v, true);
613 privUtils_.deprecationWarn(
614 'composers is deprecated since Tizen 9.0 with no replacement.',
620 if (edit_.isAllowed) {
621 composers = converter_.toArray(v, true);
628 if (lyrics === undefined) {
629 lyrics = getLyrics();
634 if (edit_.isAllowed && type_.isObject(v)) {
635 lyrics = new AudioContentLyrics(v);
642 privUtils_.deprecationWarn(
643 'copyright is deprecated since Tizen 9.0 with no replacement.',
649 if (edit_.isAllowed) {
650 copyright = converter_.toString(v, false);
657 privUtils_.deprecationWarn(
658 'bitrate is deprecated since Tizen 9.0 with no replacement.',
664 if (edit_.isAllowed) {
665 bitrate = converter_.toUnsignedLong(v, false);
675 if (edit_.isAllowed) {
676 trackNumber = converter_.toUnsignedLong(v, false);
683 privUtils_.deprecationWarn(
684 'duration is deprecated since Tizen 9.0 with no replacement.',
690 if (edit_.isAllowed) {
691 duration = converter_.toUnsignedLong(v, false);
698 if (type_.isObject(data)) {
699 // fill object with data
701 for (var key in data) {
702 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
703 this[key] = data[key];
710 AudioContent.prototype = new Content();
711 AudioContent.prototype.constructor = AudioContent;
713 function ImageContent(data) {
714 Content.call(this, data);
716 var editableAttributes = this.editableAttributes;
722 Object.defineProperties(this, {
723 editableAttributes: {
725 privUtils_.deprecationWarn(
726 'editableAttributes is deprecated since Tizen 9.0 with no replacement.',
729 return editableAttributes;
731 set: function () { },
736 privUtils_.deprecationWarn(
737 'geolocation is deprecated since Tizen 9.0 with no replacement.',
740 // for keep geolocation's latitude and longitude readonly
741 // we need to return copy of this object
742 return new tizen.SimpleCoordinates(
743 geolocation.latitude,
744 geolocation.longitude
748 // since 5.5 this attribute is readonly, it is disallowed to modify it
749 if (edit_.isAllowed) {
750 if (!type_.isNull(v)) {
751 var latitude = converter_.toDouble(v.latitude, false);
752 var longitude = converter_.toDouble(v.longitude, false);
753 geolocation = new tizen.SimpleCoordinates(latitude, longitude);
757 'Since 5.5 "geolocation" attribute is readonly, modifying it ' +
769 if (edit_.isAllowed) {
770 width = converter_.toUnsignedLong(v, false);
780 if (edit_.isAllowed) {
781 height = converter_.toUnsignedLong(v, false);
791 // since 5.5 this attribute is readonly, it is disallowed to modify it
792 if (edit_.isAllowed) {
793 if (!type_.isNull(v)) {
794 orientation = converter_.toEnum(
796 Object.keys(ImageContentOrientation),
802 'Since 5.5 "orientation" attribute is readonly, modifying it ' +
811 if (type_.isObject(data)) {
812 // fill object with data
814 for (var key in data) {
815 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
816 this[key] = data[key];
823 ImageContent.prototype = new Content();
824 ImageContent.prototype.constructor = ImageContent;
826 function PlaylistItem(data) {
829 Object.defineProperties(this, {
835 if (edit_.isAllowed && v instanceof Content) {