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 () { },
150 if (edit_.isAllowed) {
151 id = converter_.toString(v, false);
161 // since 5.5 this attribute is readonly, it is disallowed to modify it
162 if (edit_.isAllowed) {
163 if (!type_.isNull(v)) {
164 name = converter_.toString(v, false);
168 'Since 5.5 "name" attribute is readonly, modifying it has no ' +
180 if (edit_.isAllowed) {
181 type = converter_.toEnum(v, Object.keys(ContentType), false);
191 if (edit_.isAllowed) {
192 mimeType = converter_.toString(v, false);
202 if (edit_.isAllowed) {
203 title = converter_.toString(v, false);
213 if (edit_.isAllowed) {
214 contentURI = convertPathToUri_(v);
221 return thumbnailURIs;
224 if (edit_.isAllowed) {
225 thumbnailURIs = converter_.toArray(v, true);
232 privUtils_.deprecationWarn(
233 'releaseDate is deprecated since Tizen 9.0 with no replacement.',
239 if (edit_.isAllowed) {
240 releaseDate = v > 0 ? new Date(v * 1000) : null;
250 if (edit_.isAllowed) {
251 modifiedDate = v > 0 ? new Date(v * 1000) : null;
261 if (edit_.isAllowed) {
262 size = converter_.toUnsignedLong(v, false);
269 privUtils_.deprecationWarn(
270 'description is deprecated since Tizen 9.0 with no replacement.',
276 // since 5.5 this attribute is readonly, it is disallowed to modify it
277 if (edit_.isAllowed) {
278 description = converter_.toString(v, true);
281 'Since 5.5 "description" attribute is readonly, modifying it ' +
290 privUtils_.deprecationWarn(
291 'rating is deprecated since Tizen 9.0 with no replacement.',
297 // since 5.5 this attribute is readonly, it is disallowed to modify it
298 if (edit_.isAllowed) {
299 if (!type_.isNull(v) && v >= 0 && v <= 10) {
300 rating = converter_.toUnsignedLong(v, false);
304 'Since 5.5 "rating" attribute is readonly, modifying it has no ' +
313 privUtils_.deprecationWarn(
314 'isFavorite is deprecated since Tizen 9.0 with no replacement.',
320 privUtils_.deprecationWarn(
321 'isFavorite is deprecated since Tizen 9.0 with no replacement.',
324 if (!type_.isNull(v)) {
325 isFavorite = converter_.toBoolean(v, false);
332 if (type_.isObject(data)) {
333 // fill object with data
335 for (var key in data) {
336 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
337 this[key] = data[key];
344 function VideoContent(data) {
345 Content.call(this, data);
347 var editableAttributes = this.editableAttributes;
355 Object.defineProperties(this, {
356 editableAttributes: {
358 privUtils_.deprecationWarn(
359 'editableAttributes is deprecated since Tizen 9.0 with no replacement.',
362 return editableAttributes;
364 set: function () { },
370 privUtils_.deprecationWarn(
371 'geolocation is deprecated since Tizen 9.0 with no replacement.',
374 // for keep geolocation's latitude and longitude readonly
375 // we need to return copy of this object
376 return new tizen.SimpleCoordinates(
377 geolocation.latitude,
378 geolocation.longitude
382 // since 5.5 this attribute is readonly, it is disallowed to modify it
383 if (edit_.isAllowed) {
384 if (!type_.isNull(v)) {
385 var latitude = converter_.toDouble(v.latitude, false);
386 var longitude = converter_.toDouble(v.longitude, false);
387 geolocation = new tizen.SimpleCoordinates(latitude, longitude);
391 'Since 5.5 "geolocation" attribute is readonly, modifying it ' +
400 privUtils_.deprecationWarn(
401 'album is deprecated since Tizen 9.0 with no replacement.',
407 if (edit_.isAllowed) {
408 album = converter_.toString(v, false);
415 privUtils_.deprecationWarn(
416 'artists is deprecated since Tizen 9.0 with no replacement.',
422 if (edit_.isAllowed) {
423 artists = converter_.toArray(v, true);
430 privUtils_.deprecationWarn(
431 'duration is deprecated since Tizen 9.0 with no replacement.',
437 if (edit_.isAllowed) {
438 duration = converter_.toUnsignedLong(v, false);
445 privUtils_.deprecationWarn(
446 'width is deprecated since Tizen 9.0 with no replacement.',
452 if (edit_.isAllowed) {
453 width = converter_.toUnsignedLong(v, false);
460 privUtils_.deprecationWarn(
461 'height is deprecated since Tizen 9.0 with no replacement.',
467 if (edit_.isAllowed) {
468 height = converter_.toUnsignedLong(v, false);
475 if (type_.isObject(data)) {
476 // fill object with data
478 for (var key in data) {
479 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
480 this[key] = data[key];
487 VideoContent.prototype = new Content();
488 VideoContent.prototype.constructor = VideoContent;
490 function AudioContentLyrics(data) {
495 Object.defineProperties(this, {
501 if (edit_.isAllowed) {
502 type = converter_.toEnum(
504 Object.keys(AudioContentLyricsType),
516 if (edit_.isAllowed) {
517 timestamps = converter_.toArray(v, true);
527 if (edit_.isAllowed) {
528 texts = converter_.toArray(v, false);
535 if (type_.isObject(data)) {
536 // fill object with data
538 for (var key in data) {
539 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
540 this[key] = data[key];
547 function AudioContent(data) {
548 Content.call(this, data);
560 var getLyrics = function() {
562 contentURI: convertUriToPath_(this.contentURI)
565 var result = native_.callSync('ContentManagerAudioGetLyrics', data);
567 if (native_.isFailure(result)) {
568 utils_.log('Getting lyrics failed for ' + data.contentURI);
569 var error_object = native_.getErrorObject(result);
570 if (WebAPIException.SECURITY_ERR == error_object.code) {
576 return new AudioContentLyrics(native_.getResultObject(result));
579 Object.defineProperties(this, {
585 if (edit_.isAllowed) {
586 album = converter_.toString(v, false);
596 if (edit_.isAllowed) {
597 genres = converter_.toArray(v, true);
607 if (edit_.isAllowed) {
608 artists = converter_.toArray(v, true);
615 privUtils_.deprecationWarn(
616 'composers is deprecated since Tizen 9.0 with no replacement.',
622 if (edit_.isAllowed) {
623 composers = converter_.toArray(v, true);
630 if (lyrics === undefined) {
631 lyrics = getLyrics();
636 if (edit_.isAllowed && type_.isObject(v)) {
637 lyrics = new AudioContentLyrics(v);
644 privUtils_.deprecationWarn(
645 'copyright is deprecated since Tizen 9.0 with no replacement.',
651 if (edit_.isAllowed) {
652 copyright = converter_.toString(v, false);
659 privUtils_.deprecationWarn(
660 'bitrate is deprecated since Tizen 9.0 with no replacement.',
666 if (edit_.isAllowed) {
667 bitrate = converter_.toUnsignedLong(v, false);
677 if (edit_.isAllowed) {
678 trackNumber = converter_.toUnsignedLong(v, false);
685 privUtils_.deprecationWarn(
686 'duration is deprecated since Tizen 9.0 with no replacement.',
692 if (edit_.isAllowed) {
693 duration = converter_.toUnsignedLong(v, false);
700 if (type_.isObject(data)) {
701 // fill object with data
703 for (var key in data) {
704 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
705 this[key] = data[key];
712 AudioContent.prototype = new Content();
713 AudioContent.prototype.constructor = AudioContent;
715 function ImageContent(data) {
716 Content.call(this, data);
718 var editableAttributes = this.editableAttributes;
724 Object.defineProperties(this, {
725 editableAttributes: {
727 privUtils_.deprecationWarn(
728 'editableAttributes is deprecated since Tizen 9.0 with no replacement.',
731 return editableAttributes;
733 set: function () { },
739 privUtils_.deprecationWarn(
740 'geolocation is deprecated since Tizen 9.0 with no replacement.',
743 // for keep geolocation's latitude and longitude readonly
744 // we need to return copy of this object
745 return new tizen.SimpleCoordinates(
746 geolocation.latitude,
747 geolocation.longitude
751 // since 5.5 this attribute is readonly, it is disallowed to modify it
752 if (edit_.isAllowed) {
753 if (!type_.isNull(v)) {
754 var latitude = converter_.toDouble(v.latitude, false);
755 var longitude = converter_.toDouble(v.longitude, false);
756 geolocation = new tizen.SimpleCoordinates(latitude, longitude);
760 'Since 5.5 "geolocation" attribute is readonly, modifying it ' +
772 if (edit_.isAllowed) {
773 width = converter_.toUnsignedLong(v, false);
783 if (edit_.isAllowed) {
784 height = converter_.toUnsignedLong(v, false);
794 // since 5.5 this attribute is readonly, it is disallowed to modify it
795 if (edit_.isAllowed) {
796 if (!type_.isNull(v)) {
797 orientation = converter_.toEnum(
799 Object.keys(ImageContentOrientation),
805 'Since 5.5 "orientation" attribute is readonly, modifying it ' +
814 if (type_.isObject(data)) {
815 // fill object with data
817 for (var key in data) {
818 if (data.hasOwnProperty(key) && this.hasOwnProperty(key)) {
819 this[key] = data[key];
826 ImageContent.prototype = new Content();
827 ImageContent.prototype.constructor = ImageContent;
829 function PlaylistItem(data) {
832 Object.defineProperties(this, {
838 if (edit_.isAllowed && v instanceof Content) {