static const std::string uri_absolute_prefix = "file:///";
}
-const std::map<std::string, media_content_orientation_e> orientationMap = {
- {"NORMAL", MEDIA_CONTENT_ORIENTATION_NORMAL},
- {"FLIP_HORIZONTAL", MEDIA_CONTENT_ORIENTATION_HFLIP},
- {"ROTATE_180", MEDIA_CONTENT_ORIENTATION_ROT_180},
- {"FLIP_VERTICAL", MEDIA_CONTENT_ORIENTATION_VFLIP},
- {"TRANSPOSE", MEDIA_CONTENT_ORIENTATION_TRANSPOSE},
- {"ROTATE_90", MEDIA_CONTENT_ORIENTATION_ROT_90},
- {"TRANSVERSE", MEDIA_CONTENT_ORIENTATION_TRANSVERSE},
- {"ROTATE_270", MEDIA_CONTENT_ORIENTATION_ROT_270},
-};
-
std::string get_date(char* tmpStr) {
ScopeLogger();
if (tmpStr) {
ScopeLogger();
int ret = MEDIA_CONTENT_ERROR_NONE;
- std::string description = content.get("description").to_str();
- int rating = std::stoi(content.get("rating").to_str());
bool is_fav = content.get("isFavorite").get<bool>();
if (NULL == media) {
return ret;
}
- ret = media_info_set_description(media, description.c_str());
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerE("Updating description failed.");
- }
-
- ret = media_info_set_rating(media, rating);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerE("Updating rating failed.");
- }
-
ret = media_info_set_favorite(media, is_fav);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
LoggerE("Updating isFavorite failed.");
LoggerE("Updating favorite failed.");
}
- if (type == MEDIA_CONTENT_TYPE_IMAGE) {
- std::string orientation = content.get("orientation").to_str();
- auto orientationToSet = orientationMap.find(orientation);
-
- if (orientationToSet != orientationMap.end()) {
- image_meta_h img;
- if (MEDIA_CONTENT_ERROR_NONE == media_info_get_image(media, &img) &&
- MEDIA_CONTENT_ERROR_NONE == image_meta_set_orientation(img, orientationToSet->second) &&
- MEDIA_CONTENT_ERROR_NONE == image_meta_update_to_db(img)) {
- LoggerD("orientation update was successful");
- } else {
- LoggerE("orientation update failed");
- }
- image_meta_destroy(img);
- }
- }
-
- if (type == MEDIA_CONTENT_TYPE_IMAGE || type == MEDIA_CONTENT_TYPE_VIDEO) {
- picojson::value geo = content.get("geolocation");
- if (geo.evaluate_as_boolean()) {
- LoggerD("geolocation is not null");
- double latitude = atof(geo.get("latitude").to_str().c_str());
- double longitude = atof(geo.get("longitude").to_str().c_str());
- ret = media_info_set_latitude(media, latitude);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerE("Updating geolocation is failed.");
- }
- ret = media_info_set_longitude(media, longitude);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerD("Updating geolocation is failed.");
- }
- } else {
- LoggerD("geolocation is null");
- }
- }
-
return MEDIA_CONTENT_ERROR_NONE;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
std::string id = content.get("id").to_str();
- std::string new_name = content.get("name").to_str();
media_info_h media = nullptr;
- char* name = nullptr;
- char* path = nullptr;
SCOPE_EXIT {
if (media) {
media_info_destroy(media);
}
- if (name) {
- free(name);
- }
- if (path) {
- free(path);
- }
};
ret = media_info_get_media_from_db(id.c_str(), &media);
LoggerE("media_info_update_to_db failed: %d", ret);
return ret;
}
- ret = media_info_get_display_name(media, &name);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerE("media_info_get_display_name failed: %d", ret);
- return ret;
- }
- const std::string name_str(name);
- if (name_str != new_name) {
- ret = media_info_get_file_path(media, &path);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerE("media_info_get_file_path failed: %d", ret);
- return ret;
- }
- std::string path_str(path);
- const size_t p = path_str.rfind(name_str);
- path_str.replace(p, name_str.length(), new_name);
- LoggerD("new media path: %s", path_str.c_str());
- ret = media_info_move_to_db(media, path_str.c_str());
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- LoggerE("media_info_move_to_db failed: %d", ret);
- return ret;
- }
- }
return ret;
}
var types_ = validator_.Types;
var native_ = new xwalk.utils.NativeManager(extension);
-var isEarlierThan55 = utils_.isAppVersionEarlierThan('5.5');
-
var EditManager = function() {
this.isAllowed = false;
};
function Content(data) {
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;
return name;
},
set: function(v) {
- // 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) {
+ // since 5.5 this attribute is readonly, it is disallowed to modify it
+ if (edit_.isAllowed) {
if (!type_.isNull(v)) {
name = converter_.toString(v, false);
}
return description;
},
set: function(v) {
- // 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) {
+ // since 5.5 this attribute is readonly, it is disallowed to modify it
+ if (edit_.isAllowed) {
description = converter_.toString(v, true);
} else {
utils_.warn(
return rating;
},
set: function(v) {
- // 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) {
+ // since 5.5 this attribute is readonly, it is disallowed to modify it
+ if (edit_.isAllowed) {
if (!type_.isNull(v) && v >= 0 && v <= 10) {
rating = converter_.toUnsignedLong(v, false);
}
Content.call(this, data);
var editableAttributes = this.editableAttributes;
- // 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;
var artists;
},
geolocation: {
get: function() {
- if (isEarlierThan55) {
- return geolocation;
- } else {
- // for keep geolocation's latitude and longitude readonly
- // we need to return copy of this object
- return new tizen.SimpleCoordinates(
- geolocation.latitude,
- geolocation.longitude
- );
- }
+ // for keep geolocation's latitude and longitude readonly
+ // we need to return copy of this object
+ return new tizen.SimpleCoordinates(
+ geolocation.latitude,
+ geolocation.longitude
+ );
},
set: function(v) {
- // 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) {
+ // since 5.5 this attribute is readonly, it is disallowed to modify it
+ if (edit_.isAllowed) {
if (!type_.isNull(v)) {
var latitude = converter_.toDouble(v.latitude, false);
var longitude = converter_.toDouble(v.longitude, false);
Content.call(this, data);
var editableAttributes = this.editableAttributes;
- // 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;
var height;
},
geolocation: {
get: function() {
- if (isEarlierThan55) {
- return geolocation;
- } else {
- // for keep geolocation's latitude and longitude readonly
- // we need to return copy of this object
- return new tizen.SimpleCoordinates(
- geolocation.latitude,
- geolocation.longitude
- );
- }
+ // for keep geolocation's latitude and longitude readonly
+ // we need to return copy of this object
+ return new tizen.SimpleCoordinates(
+ geolocation.latitude,
+ geolocation.longitude
+ );
},
set: function(v) {
- // 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) {
+ // since 5.5 this attribute is readonly, it is disallowed to modify it
+ if (edit_.isAllowed) {
if (!type_.isNull(v)) {
var latitude = converter_.toDouble(v.latitude, false);
var longitude = converter_.toDouble(v.longitude, false);
return orientation;
},
set: function(v) {
- // 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) {
+ // since 5.5 this attribute is readonly, it is disallowed to modify it
+ if (edit_.isAllowed) {
if (!type_.isNull(v)) {
orientation = converter_.toEnum(
v,