For compliance reasons constructors should not be exported into tizen namespace,
but should be available internally to allow throwing exceptions from modules.
Change related to http://168.219.209.56/gerrit/#/c/23472/
[Verification] TCT pass rate:
- tizen 77/81 (all WebAPIException related TCs should pass)
- other modules - results without change
Change-Id: I58e5dc9932b24afc8516a37564ac1497618e709f
displayName: { enumerable: true, writable: false, value: data.displayName },
iconUri: { enumerable: true, writable: false, value: data.iconUri },
smallIconUri: { enumerable: true, writable: false, value: data.smallIconUri },
- capabilities: { enumerable: true,
+ capabilities: { enumerable: true,
set: function() {},
get: function() { return internal_; }
},
]);
var result = native_.callSync('Account_getExtendedDataSync',
- {
+ {
accountId: this.id,
key: args.key
}
// TODO handling exceptions
native_.call('AccountManager_getAccounts',
- {
+ {
applicationId: args.applicationId
},
function(result) {
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] === 'success') {
} else if (result['status'] === 'error') {
var err = result['error'];
if (err) {
- throw new tizen.WebAPIException(err.name, err.message);
+ throw new WebAPIException(err.name, err.message);
}
return false;
}
defineReadWriteNonNullProperty(this, 'key', key);
defineReadWriteNonNullProperty(this, 'value', value);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
};
defineReadWriteProperty(this, 'data', data);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
};
}
console.log("REAL PATH:" + _fileRealPath);
if (_fileRealPath === "undefined" || _fileRealPath === "null") {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
return _fileRealPath;
};
function checkMode(mode, access)
{ if(access.indexOf(mode) == -1) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_ACCESS_ERR, 'Not allowed operation');
+ throw new WebAPIException(WebAPIException.INVALID_ACCESS_ERR, 'Not allowed operation');
}
}
}
if (data === null || typeof data !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
propertyFactory_(this, 'name', data.name || "", Property.E);
function getHandle() {
if(priv.handle)
return priv.handle;
- else throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, 'Archive is not opened');
+ else throw new WebAPIException(WebAPIException.UNKNOWN_ERR, 'Archive is not opened');
}
/**
opId = getNextOpId();
if (!CommonFS.isVirtualPath(args.destinationDirectory)) //TODO: add FileReferece validation
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
"Destination directory should be virtual path or file.");
bridge.async({
cmd: 'ArchiveFileEntry_extract',
if (args.onerror) {
args.onerror.call(
null,
- new tizen.WebAPIException(e)
+ new WebAPIException(e)
);
}
},
}
if (data === null || typeof data !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
propertyFactory_(this, 'mode' , data.mode || "r", Property.E);
function getHandle() {
if(priv.handle)
return priv.handle;
- else throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_STATE_ERR, 'ArchiveFile closed - operation not permitted');
+ else throw new WebAPIException(WebAPIException.INVALID_STATE_ERR, 'ArchiveFile closed - operation not permitted');
}
/**
opId = getNextOpId();
if (!CommonFS.isVirtualPath(args.sourceFile)) //TODO: add FileReferece validation
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
"sourceFile should be virtual path or file.");
var optionsAttributes = ["destination", "stripSourceDirectory", "compressionLevel"],
if (args.onerror) {
args.onerror.call(
null,
- new tizen.WebAPIException(e)
+ new WebAPIException(e)
);
}
},
opId = getNextOpId();
if (!CommonFS.isVirtualPath(args.destinationDirectory)) //TODO: add FileReferece validation
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
"destinationDirectory should be virtual path or file.");
checkMode(this.mode, ["r","rw"]);
if (args.onerror) {
args.onerror.call(
null,
- new tizen.WebAPIException(e)
+ new WebAPIException(e)
);
}
},
if (args.onerror) {
args.onerror.call(
null,
- new tizen.WebAPIException(e)
+ new WebAPIException(e)
);
}
}
if (args.onerror) {
args.onerror.call(
null,
- new tizen.WebAPIException(e)
+ new WebAPIException(e)
);
}
}
}
if (!CommonFS.isVirtualPath(args.file)) //TODO: add FileReferece validation
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
"file should be virtual path or file.");
bridge.async({
if (args.onerror) {
args.onerror.call(
null,
- new tizen.WebAPIException(e)
+ new WebAPIException(e)
);
}
}
*/
BadgeManager.prototype.setBadgeCount = function() {
if (arguments.length < 2)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'incorrect number of arguments');
var args = validator_.validateArgs(arguments, [
]);
if (args.count < 0)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Count parameter is negative!');
var ret = native_.callSync('BadgeManager_setBadgeCount', {
*/
BadgeManager.prototype.getBadgeCount = function() {
if (arguments.length < 1)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'incorrect number of arguments');
var args = validator_.validateArgs(arguments, [
{name: 'appId', type: types_.STRING}
*/
BadgeManager.prototype.addChangeListener = function() {
if (arguments.length < 2)
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'incorrect number of arguments');
var args = validator_.validateArgs(arguments, [
{
*/
BadgeManager.prototype.removeChangeListener = function() {
if (arguments.length < 1)
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'incorrect number of arguments');
var args = validator_.validateArgs(arguments, [
return new BluetoothHealthProfileHandler(callArgs);
default:
- throw new tizen.WebAPIException('NotSupportedError', 'Profile ' + args.profileType + ' is not supported.');
+ throw new WebAPIException('NotSupportedError', 'Profile ' + args.profileType + ' is not supported.');
}
}
};
if (arguments.length === 0 || args.parentFolder === null) {
result = provider.getFolderItems(provider.getRootId(), args.recursive);
if (!result)
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
return result;
}
if (args.parentFolder.id === null || args.parentFolder.id === 0)
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
result = provider.getFolderItems(args.parentFolder.id, args.recursive);
if (!result)
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
return result;
};
]);
if (arguments.length == 1 || args.parentFolder === null) {
if (args.bookmark.id) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
if (!provider.addToFolder(args.bookmark, provider.getRootId())) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
return;
}
if (!args.parentFolder.id) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
if (!provider.addToFolder(args.bookmark, args.parentFolder.id)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
};
if (!arguments.length || args.bookmark === null) {
if (native_.isFailure(native_.callSync('Bookmark_removeAll')))
- throw new tizen.WebAPIException(tizen.WebAPIException.SECURITY_ERR);
+ throw new WebAPIException(WebAPIException.SECURITY_ERR);
return;
}
if (!args.bookmark.id)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
if (native_.isFailure(native_.callSync('Bookmark_remove', {
id: args.bookmark.id})))
- throw new tizen.WebAPIException(tizen.WebAPIException.SECURITY_ERR);
+ throw new WebAPIException(WebAPIException.SECURITY_ERR);
_edit.allow();
args.bookmark.id = null;
});
if (native_.isFailure(ret)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var folder = native_.getResultObject(ret);
if (folder === undefined || folder === null)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
var obj = new tizen.BookmarkFolder(folder[0].title);
obj.id = folder[0].id;
});
if (native_.isFailure(ret)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var folder = native_.getResultObject(ret);
if (folder === undefined)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
var item;
var obj;
var args;
if (this.type === CalendarType.TASK) {
if (!parseInt(id) || parseInt(id) <= 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
args = validator_.validateArgs(arguments, [{
name: 'id',
if ((this.type === CalendarType.EVENT && !(args.item instanceof CalendarEvent)) ||
(this.type === CalendarType.TASK && !(args.item instanceof CalendarTask))) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Invalid item type.');
}
for (var i = 0; i < args.items.length; i++) {
if ((this.type === CalendarType.EVENT && !(args.items[i] instanceof CalendarEvent)) ||
(this.type === CalendarType.TASK && !(args.items[i] instanceof CalendarTask))) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Invalid item type.');
}
tmpItem = _itemConverter.fromTizenObject(args.items[i]);
if ((this.type === CalendarType.EVENT && !(args.item instanceof CalendarEvent)) ||
(this.type === CalendarType.TASK && !(args.item instanceof CalendarTask))) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Invalid item type.');
}
for (var i = 0; i < args.items.length; i++) {
if ((calendarType === CalendarType.EVENT && !(args.items[i] instanceof CalendarEvent)) ||
(calendarType === CalendarType.TASK && !(args.items[i] instanceof CalendarTask))) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Invalid item type.');
}
tmpItem = _itemConverter.fromTizenObject(args.items[i]);
var args;
if (this.type === CalendarType.TASK) {
if (!parseInt(id) || parseInt(id) <= 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
args = validator_.validateArgs(arguments, [{
name: 'id',
var _validateReccurence = function(v) {
if (_isDetached && v !== null) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_SUPPORTED_ERR,
+ throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR,
'Recurrence can\'t be set because event is detached');
}
CalendarEvent.prototype.expandRecurrence = function(startDate, endDate, successCallback, errorCallback) {
if (arguments.length < 3) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
if (!(startDate instanceof tizen.TZDate)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
if (!(endDate instanceof tizen.TZDate)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
if (typeof successCallback !== 'function') {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
if (errorCallback) {
if (typeof errorCallback !== 'function') {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
}
if (!(this.recurrenceRule instanceof tizen.CalendarRecurrenceRule)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'The event is not recurring.');
}
]);
if (isNaN(Number(args.id))) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Calendar not found');
}
ListenerManager.prototype.removeListener = function(watchId) {
if (this.listeners[watchId] === null || this.listeners[watchId] === undefined) {
- throw new tizen.WebAPIException(0, 'Watch id not found.', 'InvalidValuesError');
+ throw new WebAPIException(0, 'Watch id not found.', 'InvalidValuesError');
}
if (this.listeners.hasOwnProperty(watchId)) {
var result = native_.callSync('CallHistory_remove', callArgs);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(
- tizen.WebAPIException.INVALID_VALUES_ERR, 'Watch id not found.');
+ throw new WebAPIException(
+ WebAPIException.INVALID_VALUES_ERR, 'Watch id not found.');
}
return;
if (String(converter_.toLong(args.id)) !== args.id) {
// TCT: AddressBook_get_id_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('AddressBook_get', {
if (String(converter_.toLong(args.id)) !== args.id) {
// TCT: AddressBook_remove_id_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('AddressBook_remove', {
]);
if (args.watchId <= 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Wrong watch id');
}
if (!_contactCallbackMap.hasOwnProperty(this.id) ||
!_contactCallbackMap[this.id].hasOwnProperty(args.watchId)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'watch id not found for this address book');
}
if (String(converter_.toLong(args.groupId)) !== args.groupId) {
// TCT: AddressBook_getGroup_groupId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('AddressBook_getGroup', {
if (String(converter_.toLong(args.groupId)) !== args.groupId) {
// TCT: AddressBook_removeGroup_groupId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('AddressBook_removeGroup',
format = format || TypeEnum[0];
if (!type_.isString(format)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format');
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format');
}
if (TypeEnum.indexOf(format) < 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format');
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format');
}
if (this.id === '') {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Contact ID is empty.');
}
// TODO check privileges
//var result = native_.callSync('CheckReadPrivileges', {});
//if (native_.isFailure(result)) {
- // throw new tizen.WebAPIException(WebAPIException.SECURITY_ERR,
+ // throw new WebAPIException(WebAPIException.SECURITY_ERR,
// 'You do not have privileges for this operation');
//}
if (String(converter_.toLong(args.addressBookId)) !== args.addressBookId) {
// TCT: ContactManager_getAddressBook_addressBookId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
var result = native_.callSync('ContactManager_getAddressBook', {
ContactManager.prototype.removeAddressBook = function() {
// TCT: ContactManager_removeAddressBook_misarg
if (type_.isNullOrUndefined(arguments[0])) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var args = validator_.validateArgs(arguments, [{
}]);
if (args.addressBookId === UNIFIED_ADDRESSBOOK_ID) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Unified address book can not be deleted');
}
if (args.addressBookId === DEFAULT_ADDRESSBOOK_ID) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Default address book can not be deleted');
}
if (String(converter_.toLong(args.personId)) !== args.personId) {
// TCT: ContactManager_get_personId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('ContactManager_get', {
if (String(converter_.toLong(args.personId)) !== args.personId) {
// TCT: ContactManager_remove_personId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('ContactManager_remove', {personId: args.personId});
// This makes UTC_contact_removeChangeListenerPerson_N_001 pass.
// watch id's start at 1
if (args.watchId === 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'id is null or undefined');
}
if (args.watchId < 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Negative watch id');
}
if (!_personCallbackMap.hasOwnProperty(args.watchId)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'watch id not found');
}
if (String(converter_.toLong(args.personId)) !== args.personId) {
// TCT: Person_link_personId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('Person_link', {
if (String(converter_.toLong(args.contactId)) !== args.contactId) {
// TCT: Person_unlink_contactId_invalid
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('Person_unlink', {
var ExceptionMap = {
- 'UnknownError' : tizen.WebAPIException.UNKNOWN_ERR ,
- 'TypeMismatchError' : tizen.WebAPIException.TYPE_MISMATCH_ERR ,
- 'InvalidValuesError' : tizen.WebAPIException.INVALID_VALUES_ERR ,
- 'IOError' : tizen.WebAPIException.IO_ERR ,
- 'ServiceNotAvailableError' : tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR ,
- 'SecurityError' : tizen.WebAPIException.SECURITY_ERR ,
- 'NetworkError' : tizen.WebAPIException.NETWORK_ERR ,
- 'NotSupportedError' : tizen.WebAPIException.NOT_SUPPORTED_ERR ,
- 'NotFoundError' : tizen.WebAPIException.NOT_FOUND_ERR ,
- 'InvalidAccessError' : tizen.WebAPIException.INVALID_ACCESS_ERR ,
- 'AbortError' : tizen.WebAPIException.ABORT_ERR ,
- 'QuotaExceededError' : tizen.WebAPIException.QUOTA_EXCEEDED_ERR ,
+ 'UnknownError' : WebAPIException.UNKNOWN_ERR ,
+ 'TypeMismatchError' : WebAPIException.TYPE_MISMATCH_ERR ,
+ 'InvalidValuesError' : WebAPIException.INVALID_VALUES_ERR ,
+ 'IOError' : WebAPIException.IO_ERR ,
+ 'ServiceNotAvailableError' : WebAPIException.SERVICE_NOT_AVAILABLE_ERR ,
+ 'SecurityError' : WebAPIException.SECURITY_ERR ,
+ 'NetworkError' : WebAPIException.NETWORK_ERR ,
+ 'NotSupportedError' : WebAPIException.NOT_SUPPORTED_ERR ,
+ 'NotFoundError' : WebAPIException.NOT_FOUND_ERR ,
+ 'InvalidAccessError' : WebAPIException.INVALID_ACCESS_ERR ,
+ 'AbortError' : WebAPIException.ABORT_ERR ,
+ 'QuotaExceededError' : WebAPIException.QUOTA_EXCEEDED_ERR ,
}
function callNative(cmd, args) {
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] == 'success') {
var err = result['error'];
if(err) {
if(ExceptionMap[err.name]) {
- throw new tizen.WebAPIException(ExceptionMap[err.name], err.message);
+ throw new WebAPIException(ExceptionMap[err.name], err.message);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, err.message);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR, err.message);
}
}
return false;
});
} catch(e) {
throw e;
- }
+ }
}
Playlist.prototype.get = function() {
var args = validator_.validateArgs(arguments, [
- {'name' : 'successCallback', 'type': types_.FUNCTION},
+ {'name' : 'successCallback', 'type': types_.FUNCTION},
{'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
{'name' : 'count', 'type': types_.LONG, optional : true, nullable : true},
{'name' : 'offset', 'type': types_.LONG, optional : true, nullable : true}
else {
nativeParam['offset'] = -1;
}
-
+
try {
var syncResult = callNativeWithCallback('ContentPlaylist_get', nativeParam, function(result) {
if (result.status == 'success') {
});
} catch(e) {
throw e;
- }
+ }
}
Playlist.prototype.move = function(item, delta) {
'member_id': args.item.member_id,
'delta' : args.delta
};
-
+
try {
var syncResult = callNativeWithCallback('ContentPlaylist_move', nativeParam, function(result) {
function ContentDirectory(id, uri, type, title, date) {
Object.defineProperties(this, {
- 'id': { writable: false, value: id, enumerable: true },
+ 'id': { writable: false, value: id, enumerable: true },
'directoryURI': { writable: false, value: uri, enumerable: true },
'title': { writable: false, value: title, enumerable: true },
'storageType': { writable: false, value: type, enumerable: true },
}
-function Content(id, name,type, mimeType, title, contentURI, thumbnailURIs,
+function Content(id, name,type, mimeType, title, contentURI, thumbnailURIs,
releaseDate, modifiedDate, size, description, rating, isFavorite) {
var name_ = name;
var rating_ = rating;
editableAttributes_.push("geolocation");
}
Object.defineProperties(this, {
- 'editableAttributes':
+ 'editableAttributes':
{ enumerable: true,
get: function() { return editableAttributes_; }
},
- 'id':
+ 'id':
{ writable: false, value: id, enumerable: true },
- 'name':
+ 'name':
{ enumerable: true,
set: function(v) { if (v != null) name_ = v},
get: function() { return name_; }
- },
- 'type':
+ },
+ 'type':
{ writable: false, value: type, enumerable: true },
- 'mimeType':
+ 'mimeType':
{ writable: false, value: mimeType, enumerable: true },
- 'title':
+ 'title':
{ writable: false, value: title, enumerable: true },
- 'contentURI':
+ 'contentURI':
{ writable: false, value: contentURI, enumerable: true },
- 'thumbnailURIs':
+ 'thumbnailURIs':
{ writable: false, value: thumbnailURIs, enumerable: true },
- 'releaseDate':
+ 'releaseDate':
{ writable: false, value: releaseDate, enumerable: true },
- 'modifiedDate':
+ 'modifiedDate':
{ writable: false, value: modifiedDate, enumerable: true },
- 'size':
+ 'size':
{ writable: false, value: size, enumerable: true },
- 'description':
+ 'description':
{ writable: true, value: description, enumerable: true },
- 'rating':
+ 'rating':
{ enumerable: true,
set: function(v) { if (v != null && v >= 0 && v <= 10) rating_ = v; },
get: function() { return rating_; }
},
- 'isFavorite':
+ 'isFavorite':
{ writable: true, value: isFavorite, enumerable: true }
});
}
function ImageContent(obj, width, height, orientation, geolocation) {
Object.defineProperties(obj, {
- 'width':
+ 'width':
{ writable: false, value: width, enumerable: true },
- 'height':
+ 'height':
{ writable: false, value: height, enumerable: true },
- 'orientation':
+ 'orientation':
{ writable: true, value: orientation, enumerable: true },
- 'geolocation':
+ 'geolocation':
{ writable: true, value: geolocation, enumerable: true }
});
}
function VideoContent(obj, geolocation, album, artists, duration, width, height) {
Object.defineProperties(obj, {
- 'geolocation':
+ 'geolocation':
{ writable: true, value: geolocation, enumerable: true },
- 'album':
+ 'album':
{ writable: false, value: album, enumerable: true },
- 'artists':
+ 'artists':
{ writable: false, value: artists, enumerable: true },
- 'duration':
+ 'duration':
{ writable: false, value: duration, enumerable: true },
- 'width':
+ 'width':
{ writable: false, value: width, enumerable: true },
- 'height':
+ 'height':
{ writable: false, value: height, enumerable: true }
});
}
function AudioContentLyrics(type, timestamps, texts) {
Object.defineProperties(this, {
- 'type':
+ 'type':
{ writable: false, value: type, enumerable: true },
- 'timestamps':
+ 'timestamps':
{ writable: false, value: timestamps, enumerable: true },
- 'texts':
+ 'texts':
{ writable: false, value: texts, enumerable: true }
});
}
}
}
Object.defineProperties(obj, {
- 'album':
+ 'album':
{ writable: false, value: album, enumerable: true },
- 'genres':
+ 'genres':
{ writable: false, value: genres, enumerable: true },
- 'artists':
+ 'artists':
{ writable: false, value: artists, enumerable: true },
- 'composers':
+ 'composers':
{ writable: false, value: composers, enumerable: true },
- 'copyright':
+ 'copyright':
{ writable: false, value: copyright, enumerable: true },
- 'bitrate':
+ 'bitrate':
{ writable: false, value: bitrate, enumerable: true },
- 'trackNumber':
+ 'trackNumber':
{ writable: false, value: trackNumber, enumerable: true },
- 'duration':
+ 'duration':
{ writable: false, value: duration, enumerable: true },
- 'lyrics':
+ 'lyrics':
{ enumerable: true,
- get: function() {
+ get: function() {
if(lyrics_ === undefined) {
getLyrics(obj.contentURI);
}
if (c.type === "IMAGE") {
var image = new ImageContent(content,
c.width,
- c.height,
+ c.height,
c.orientation,
c.geolocation
);
ContentManager.prototype.updateBatch = function(contents) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'contents', 'type': types_.ARRAY},
+ {'name' : 'contents', 'type': types_.ARRAY},
{'name' : 'successCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
{'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
]);
ContentManager.prototype.getDirectories = function(successCallback) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'successCallback', 'type': types_.FUNCTION, optional : false, nullable : false},
- {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
+ {'name' : 'successCallback', 'type': types_.FUNCTION, optional : false, nullable : false},
+ {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
]);
var nativeParam = {
res.storageType,
res.modifiedDate
);
-
+
dirs.push(dir);
}
args.successCallback(dirs);
ContentManager.prototype.find = function(successCallback) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'successCallback', 'type': types_.FUNCTION, 'values' : ['onsuccess']},
- {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
- {'name' : 'directoryId', 'type': types_.STRING, optional : true, nullable : true},
- {'name' : 'filter', 'type': types_.DICTIONARY, optional : true, nullable : true},
- {'name' : 'sortMode', 'type': types_.DICTIONARY, optional : true, nullable : true},
+ {'name' : 'successCallback', 'type': types_.FUNCTION, 'values' : ['onsuccess']},
+ {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
+ {'name' : 'directoryId', 'type': types_.STRING, optional : true, nullable : true},
+ {'name' : 'filter', 'type': types_.DICTIONARY, optional : true, nullable : true},
+ {'name' : 'sortMode', 'type': types_.DICTIONARY, optional : true, nullable : true},
{'name' : 'count', 'type': types_.UNSIGNED_LONG, optional : true},
{'name' : 'offset', 'type': types_.UNSIGNED_LONG, optional : true}
]);
var nativeParam = {
};
-
+
if (args['directoryId']) {
nativeParam['directoryId'] = args.directoryId;
}
var c = result.value[i];
var content = createContent(c);
-
+
contents.push(content);
}
args.successCallback(contents);
else if(result.status == 'error') {
var err = result['value'];
args.errorCallback(err);
- }
+ }
});
// if you need synchronous result from native function using 'syncResult'.
} catch(e) {
ContentManager.prototype.scanFile = function(contentURI) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'contentURI', 'type': types_.STRING},
+ {'name' : 'contentURI', 'type': types_.STRING},
{'name' : 'successCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
{'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
]);
ContentManager.prototype.setChangeListener = function(changeCallback) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'changeCallback', 'type': types_.LISTENER, 'values' : ['oncontentadded', 'oncontentupdated', 'oncontentremoved']}
+ {'name' : 'changeCallback', 'type': types_.LISTENER, 'values' : ['oncontentadded', 'oncontentupdated', 'oncontentremoved']}
]);
var nativeParam = {
ContentManager.prototype.getPlaylists = function(successCallback) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'successCallback', 'type': types_.FUNCTION},
- {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
+ {'name' : 'successCallback', 'type': types_.FUNCTION},
+ {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
]);
var nativeParam = {
ContentManager.prototype.createPlaylist = function(name, successCallback) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'name', 'type': types_.STRING},
- {'name' : 'successCallback', 'type': types_.FUNCTION},
- {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
+ {'name' : 'name', 'type': types_.STRING},
+ {'name' : 'successCallback', 'type': types_.FUNCTION},
+ {'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
{'name' : 'sourcePlaylist', 'type': types_.PLATFORM_OBJECT, optional : true, nullable : true}
]);
ContentManager.prototype.removePlaylist = function(id) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'id', 'type': types_.STRING},
+ {'name' : 'id', 'type': types_.STRING},
{'name' : 'successCallback', 'type': types_.FUNCTION, optional : true, nullable : true},
{'name' : 'errorCallback', 'type': types_.FUNCTION, optional : true, nullable : true}
]);
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] == 'success') {
} else if (result['status'] == 'error') {
var err = result['error'];
if (err) {
- throw new tizen.WebAPIException(err.name, err.message);
+ throw new WebAPIException(err.name, err.message);
}
return false;
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
if (result.status == 'error') {
if (args.errorCallback) {
var err = result['result'];
- var e = new tizen.WebAPIException(err.name, err.message);
+ var e = new WebAPIException(err.name, err.message);
args.errorCallback(result['requestId'], e);
}
}
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] == 'success') {
} else if (result['status'] == 'error') {
var err = result['error'];
if (err) {
- throw new tizen.WebAPIException(err.name, err.message);
+ throw new WebAPIException(err.name, err.message);
}
return false;
}
{'name' : 'fileName', 'type': types_.STRING, 'nullable': true, 'optional': true},
{'name' : 'networkType', 'type': types_.ENUM, 'values': ['CELLULAR', 'WIFI', 'ALL'],
'nullable' : true, 'optional': true},
- {'name' : 'httpHeader', 'type': types_.Dictionary, 'nullable': true, 'optional': true}
+ {'name' : 'httpHeader', 'type': types_.Dictionary, 'nullable': true, 'optional': true}
]);
var url_ = url;
var networkType_;
-
+
if (networkType === undefined) networkType_ = 'ALL';
else if (networkType in DownloadNetworkType) networkType_ = networkType;
};
if (typeof requests[downloadId] === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'the identifier does not match any download operation in progress');
try {
};
if (typeof requests[downloadId] === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'the identifier does not match any download operation in progress');
try {
};
if (typeof requests[downloadId] === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'the identifier does not match any download operation in progress');
try {
};
if (typeof requests[downloadId] === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'the identifier does not match any download operation in progress');
try {
]);
if (typeof requests[downloadId] === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'the identifier does not match any download operation in progress');
return requests[args.downloadId];
};
if (typeof requests[downloadId] === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'the identifier does not match any download operation in progress');
try {
if (!_isValidAbsoluteURI(args.uri)) {
setTimeout(function() {
- native_.callIfPossible(args.errorCallback, new tizen.WebAPIException(
- tizen.WebAPIException.INVALID_VALUES_ERR,
+ native_.callIfPossible(args.errorCallback, new WebAPIException(
+ WebAPIException.INVALID_VALUES_ERR,
'Invalid URI.'));
}, 0);
return;
native_.call('ExifManager_getExifInfo', {'uri': args.uri}, callback);
},
function() {
- native_.callIfPossible(args.errorCallback, new tizen.WebAPIException(
- tizen.WebAPIException.NOT_FOUND_ERR,
+ native_.callIfPossible(args.errorCallback, new WebAPIException(
+ WebAPIException.NOT_FOUND_ERR,
'File can not be found.'));
});
};
if (!_isValidAbsoluteURI(args.exifInfo.uri)) {
setTimeout(function() {
- native_.callIfPossible(args.errorCallback, new tizen.WebAPIException(
- tizen.WebAPIException.INVALID_VALUES_ERR,
+ native_.callIfPossible(args.errorCallback, new WebAPIException(
+ WebAPIException.INVALID_VALUES_ERR,
'Invalid URI.'));
}, 0);
return;
if (!_isValidAbsoluteURI(args.uri)) {
setTimeout(function() {
- native_.callIfPossible(args.errorCallback, new tizen.WebAPIException(
- tizen.WebAPIException.INVALID_VALUES_ERR,
+ native_.callIfPossible(args.errorCallback, new WebAPIException(
+ WebAPIException.INVALID_VALUES_ERR,
'Invalid URI.'));
}, 0);
return;
native_.call('ExifManager_getThumbnail', {'uri': args.uri}, _callback);
},
function() {
- native_.callIfPossible(args.errorCallback, new tizen.WebAPIException(
- tizen.WebAPIException.NOT_FOUND_ERR,
+ native_.callIfPossible(args.errorCallback, new WebAPIException(
+ WebAPIException.NOT_FOUND_ERR,
'File can not be found.'));
});
};
var exifInitDict = args.ExifInitDict;
if (exifInitDict) {
if (exifInitDict.uri === null) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Parameter "uri" is required.');
}
}
_fileFilter[i] = stringToRegex(fileFilter[i]);
} else {
if (!(fileFilter[i] instanceof Date)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Invalid date');
}
_fileFilter[i] = fileFilter[i];
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Arguments missing');
}
if (!this.isDirectory) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory'));
}, 0);
return;
if (encoding) {
var _validEncoding = Object.keys(Encoding);
if (_validEncoding.indexOf((encoding.toLowerCase())) < 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "encoding" has invalid value');
}
}
]);
if (arguments.length < 2) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Arguments missing');
}
if (this.mode === 'r' && args.mode !== 'r') {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Read only mode'));
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Read only mode'));
}, 0);
return;
}
if (this.isDirectory) {
var directoryMessage = 'This method should be called on file, not directory';
setTimeout(function() {
- native_.callIfPossible(args.onerror, new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ native_.callIfPossible(args.onerror, new WebAPIException(WebAPIException.IO_ERR,
directoryMessage));
}, 0);
return;
if (native_.isFailure(_result)) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'File does not exist'));
+ new WebAPIException(WebAPIException.IO_ERR, 'File does not exist'));
}, 0);
return;
}
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Arguments missing');
}
if (this.isDirectory) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is directory'));
}, 0);
return;
]);
if (arguments.length < 3) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Invalid arguments given');
}
if (this.isFile) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory'));
}, 0);
return;
if (!_realOriginalPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Source path is not valid'));
}, 0);
return;
if (!_realDestinationPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Destination path is not valid'));
}, 0);
return;
var callback = function(result) {
if (native_.isFailure(result)) {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, result));
+ new WebAPIException(WebAPIException.IO_ERR, result));
return;
}
native_.callIfPossible(args.onsuccess);
]);
if (arguments.length < 3) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Arguments missing');
}
if (this.isFile) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory'));
}, 0);
return;
if (!_realOriginalPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Source path is not valid'));
}, 0);
return;
if (!_realDestinationPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Destination path is not valid'));
}, 0);
return;
if (native_.isFailure(resultOldPath)) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Source file is not avalaible'));
}, 0);
return;
if (native_.isSuccess(resultNewPath)) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Overwrite is not allowed'));
+ new WebAPIException(WebAPIException.IO_ERR, 'Overwrite is not allowed'));
}, 0);
return;
}
var m1 = 'Source file should be subdirectory of: ' + this.fullPath;
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, m1));
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR, m1));
}, 0);
return;
}
var m2 = 'Source/Destination is read only folder: ' + this.fullPath;
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, m2));
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR, m2));
}, 0);
return;
}
var callback = function(result) {
if (native_.isFailure(result)) {
- native_.callIfPossible(args.onerror, new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ native_.callIfPossible(args.onerror, new WebAPIException(WebAPIException.IO_ERR,
result));
return;
}
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Invalid path');
}
if (!args.dirPath.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Invalid path');
}
if (!_realNewPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Path is not valid'));
}, 0);
return;
if (this.isDirectory) {
if (this.mode === 'r') {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Invalid path or readonly access');
}
var _resultExist = native_.callSync('File_statSync', {location: _realNewPath});
if (native_.isSuccess(_resultExist)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Directory already exist');
}
var result = native_.callSync('FileSystemManager_mkdirSync', {location: _realNewPath});
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, native_.getErrorObject(result));
+ throw new WebAPIException(WebAPIException.IO_ERR, native_.getErrorObject(result));
}
var _result = native_.callSync('File_statSync', {location: _realNewPath});
_fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode);
return new File(_fileInfo);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ throw new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory');
}
};
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Argument "relativeFilePath" missing');
}
if (this.isFile) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ throw new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory');
}
if (!commonFS_.f_isCorrectRelativePath(args.relativeFilePath) || this.mode === 'r') {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Invalid path or readonly acces');
}
if (!_outputRealPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Path is not valid'));
}, 0);
return;
var _resultExist = native_.callSync('File_statSync', {location: _outputRealPath});
if (native_.isSuccess(_resultExist)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Overwrite is not allowed');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Overwrite is not allowed');
}
var result = native_.callSync('File_createSync', {location: _outputRealPath});
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "filePath" missing');
}
if (this.isFile) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ throw new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory');
}
if (!commonFS_.f_isCorrectRelativePath(args.filePath)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Invalid path');
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Invalid path');
}
var _newPath = this.fullPath + '/' + args.filePath;
if (!_realPath) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Path is not valid'));
}, 0);
return;
}
var _result = native_.callSync('File_statSync', {location: _realPath});
if (native_.isFailure(_result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(_result));
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, native_.getErrorObject(_result));
}
var _statObj = native_.getResultObject(_result);
var _fileInfo = commonFS_.getFileInfo(_statObj, false, this.mode);
]);
if (arguments.length < 2) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Arguments missing');
}
if (this.mode === 'r') {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Invalid path or readonly access'));
}, 0);
return;
if (native_.isFailure(_result)) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'Directory not found'));
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Directory not found'));
}, 0);
return;
}
if (!_node.isDirectory) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'It is file not directory'));
}, 0);
return;
if (files.length > 0) {
if (!args.recursive) {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'Non empty folder ' + _myPath + ' passed for non recursive delete'));
return;
}
},
function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'List files failed for ' + _myPath));
}
);
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "filePath" missing');
}
if (this.isFile) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.IO_ERR,
+ new WebAPIException(WebAPIException.IO_ERR,
'File object which call this method is not directory'));
}, 0);
return;
if (native_.isFailure(_result)) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'File is not avalaible'));
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'File is not avalaible'));
}, 0);
return;
}
var message = 'Requested object is a directory.';
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, message));
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR, message));
}, 0);
return;
}
'and should be subdirectory of: [' + this.fullPath + ']';
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, _message));
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR, _message));
}, 0);
return;
}
function _checkClosed(stream) {
if (stream._closed) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Stream is closed.');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Stream is closed.');
}
}
function _checkReadAccess(mode) {
if (mode !== 'r' && mode !== 'rw') {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Stream is not in read mode.');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Stream is not in read mode.');
}
}
function _checkWriteAccess(mode) {
if (mode !== 'a' && mode !== 'w' && mode !== 'rw') {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Stream is not in write mode.');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Stream is not in write mode.');
}
}
_checkReadAccess(this._mode);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Argument "charCount" missing');
}
if (!type_.isNumber(args.charCount)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "charCount" must be a number');
}
if (args.charCount <= 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Argument "charCount" must be greater than 0');
}
var result = native_.callSync('File_readSync', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not read');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Could not read');
}
var encoded = native_.getResultObject(result);
var decoded = Base64.decode(encoded);
_checkReadAccess(this._mode);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Argument "byteCount" missing');
}
if (!type_.isNumber(args.byteCount)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "byteCount" must be a number');
}
if (args.byteCount <= 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "byteCount" must be greater than 0');
}
var result = native_.callSync('File_readSync', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Could not read');
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read');
}
var encoded = native_.getResultObject(result);
var decoded = Base64.decode(encoded);
_checkReadAccess(this._mode);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "byteCount" missing');
}
if (type_.isString(arguments[0]) && !arguments[0].length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Argument "byteCount" must be a number');
}
if (!type_.isNumber(arguments[0])) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "byteCount" must be a number');
}
if (args.byteCount <= 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "byteCount" must be greater than 0');
}
var result = native_.callSync('File_readSync', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Could not read');
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Could not read');
}
var encoded = native_.getResultObject(result);
_checkWriteAccess(this._mode);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Argument "stringData" missing');
}
var result = native_.callSync('File_writeSync', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not write');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write');
}
this.position = args.stringData.length;
};
_checkWriteAccess(this._mode);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "byteData" missing');
}
var result = native_.callSync('File_writeSync', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not write');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write');
}
};
_checkWriteAccess(this._mode);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "base64Data" missing');
}
if (!args.base64Data.length || !_isBase64(args.base64Data)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Data is not base64');
}
var result = native_.callSync('File_writeSync', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR, 'Could not write');
+ throw new WebAPIException(WebAPIException.IO_ERR, 'Could not write');
}
};
if (args.location[0] === '/') {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'Global path without \'file://\' prefix is not valid.'));
}, 0);
return;
if (args.mode !== 'r' && !_isLocationAllowed) {
setTimeout(function() {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Provided arguments are not valid.'));
}, 0);
return;
var aStatObj = native_.getResultObject(result);
var _result = commonFS_.getFileInfo(aStatObj, false, args.mode);
if (_result.readOnly && args.mode !== 'r') {
- throw new tizen.WebAPIException(tizen.WebAPIException.IO_ERR);
+ throw new WebAPIException(WebAPIException.IO_ERR);
} else {
native_.callIfPossible(args.onsuccess, new File(_result));
}
if (storage === undefined) {
native_.callIfPossible(args.onerror,
- new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'Storage not found.'));
+ new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Storage not found.'));
} else {
native_.callIfPossible(args.onsuccess, storage);
}
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Missing watchId');
}
var id = args.watchId;
if (type_.isNullOrUndefined(callbacks[id])) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR, 'Watch ID not found.');
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR, 'Watch ID not found.');
}
delete callbacks[id];
}
var ExceptionMap = {
- 'UnknownError' : tizen.WebAPIException.UNKNOWN_ERR,
- 'TypeMismatchError' : tizen.WebAPIException.TYPE_MISMATCH_ERR,
- 'InvalidValuesError' : tizen.WebAPIException.INVALID_VALUES_ERR,
- 'IOError' : tizen.WebAPIException.IO_ERR,
- 'ServiceNotAvailableError' : tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR,
- 'SecurityError' : tizen.WebAPIException.SECURITY_ERR,
- 'NetworkError' : tizen.WebAPIException.NETWORK_ERR,
- 'NotSupportedError' : tizen.WebAPIException.NOT_SUPPORTED_ERR,
- 'NotFoundError' : tizen.WebAPIException.NOT_FOUND_ERR,
- 'InvalidAccessError' : tizen.WebAPIException.INVALID_ACCESS_ERR,
- 'AbortError' : tizen.WebAPIException.ABORT_ERR,
- 'QuotaExceededError' : tizen.WebAPIException.QUOTA_EXCEEDED_ERR
+ 'UnknownError' : WebAPIException.UNKNOWN_ERR,
+ 'TypeMismatchError' : WebAPIException.TYPE_MISMATCH_ERR,
+ 'InvalidValuesError' : WebAPIException.INVALID_VALUES_ERR,
+ 'IOError' : WebAPIException.IO_ERR,
+ 'ServiceNotAvailableError' : WebAPIException.SERVICE_NOT_AVAILABLE_ERR,
+ 'SecurityError' : WebAPIException.SECURITY_ERR,
+ 'NetworkError' : WebAPIException.NETWORK_ERR,
+ 'NotSupportedError' : WebAPIException.NOT_SUPPORTED_ERR,
+ 'NotFoundError' : WebAPIException.NOT_FOUND_ERR,
+ 'InvalidAccessError' : WebAPIException.INVALID_ACCESS_ERR,
+ 'AbortError' : WebAPIException.ABORT_ERR,
+ 'QuotaExceededError' : WebAPIException.QUOTA_EXCEEDED_ERR
};
function callNative(cmd, args) {
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] == 'success') {
var err = result['error'];
if (err) {
if (ExceptionMap[err.name]) {
- throw new tizen.WebAPIException(ExceptionMap[err.name], err.message);
+ throw new WebAPIException(ExceptionMap[err.name], err.message);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, err.message);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR, err.message);
}
}
return false;
}
if (typeof to_delete === 'undefined')
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
'The port of the target application is not found.');
listeners.splice(to_delete, 1);
for (var i = 0, j = data.length; i < j; i++) {
if (Object.hasOwnProperty(data[i], 'key'))
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'The input parameter contains an invalid value.');
if (Object.hasOwnProperty(data[i], 'value'))
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'The input parameter contains an invalid value.');
filtered_data[i] = { key: data[i].key, value: data[i].value };
}
var bridge = xwalk.utils.NativeBridge(extension, true);
function throwException_(err) {
- throw new tizen.WebAPIException(err.code, err.name, err.message);
+ throw new WebAPIException(err.code, err.name, err.message);
}
var Property = {
throw new TypeError("Constructor called like a function");
}
if (MessageServiceTag.indexOf(type) === -1) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
if ( !data || typeof data !== 'object') { // 'data' is optional
data = {};
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
// Additionally to pass the MessageService_email_stopSync_opId_TypeMismatch test
if (!isFinite(arguments[0])) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
var self = this;
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
args.conversations.forEach(function (el) {
if (!el || el.constructor !== MessageConversation) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
});
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
if (args.errorCallback) {
args.errorCallback.call(
null,
- new tizen.WebAPIException(e.code, e.message, e.name)
+ new WebAPIException(e.code, e.message, e.name)
)
}
}
{}
);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
}
// If failed then exception should be thrown.
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
// Uncoment line below (and remove line above) when problem
// with error conversion is fixed:
if (!type_.isNullOrUndefined(args.tagType)) {
for (var i = 0; i < args.tagType.length; i++) {
if (NFCTagType[args.tagType[i]] === undefined) {
- throw new tizen.WebAPIException(
- tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid tag type.');
+ throw new WebAPIException(
+ WebAPIException.TYPE_MISMATCH_ERR, 'Invalid tag type.');
}
}
}
var result = native_.callSync(
'NFCAdapter_addCardEmulationModeChangeListener');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
}
}
result = native_.callSync('NFCAdapter_addTransactionEventListener', {
type: args.type});
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
}
}
result = native_.callSync('NFCAdapter_addTransactionEventListener', {
type: args.type});
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
}
}
var result = native_.callSync(
'NFCAdapter_addActiveSecureElementChangeListener');
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
}
}
var len = convertedArray.length;
if (len > max_size)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
for (var i = 0; i < len; i++) {
resultArray.push(converter_.toOctet(convertedArray[i]));
}
}
}
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
}
} catch (e) {
}
);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
// throw native_.getErrorObject(result);
}
id_ = toByteArray(id, 255, true, []);
}
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
} catch (e) {
//constructor call failed - empty object should be created
}
);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
// throw native_.getErrorObject(result);
}
tizen.NDEFRecord.call(this, result.result.tnf, result.result.type,
result.result.payload, result.result.id);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
} catch (e) {
//constructor call failed - empty object should be created
}
);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
// throw native_.getErrorObject(result);
}
tizen.NDEFRecord.call(this, result.result.tnf, result.result.type,
result.result.payload, result.result.id);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
} catch (e) {
//constructor call failed - empty object should be created
}
);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(0, result.error.message,
+ throw new WebAPIException(0, result.error.message,
result.error.name);
// throw native_.getErrorObject(result);
}
tizen.NDEFRecord.call(this, result.result.tnf, result.result.type,
result.result.payload, result.result.id);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
} catch (e) {
//constructor call failed - empty object should be created
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
var data = {
var result = native_.callSync('NotificationManager_update', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
native_.getErrorObject(result));
}
};
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
var data = {
var result = native_.callSync('NotificationManager_remove', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
native_.getErrorObject(result));
}
};
]);
if (!arguments.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR);
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR);
}
var data = {
var result = native_.callSync('NotificationManager_get', data);
if (native_.isFailure(result)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_FOUND_ERR,
+ throw new WebAPIException(WebAPIException.NOT_FOUND_ERR,
native_.getErrorObject(result));
}
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] == 'success') {
} else if (result['status'] == 'error') {
var err = result['error'];
if (err) {
- throw new tizen.WebAPIException(err.name, err.message);
+ throw new WebAPIException(err.name, err.message);
}
return false;
}
}
var ExceptionMap = {
- 'UnknownError' : tizen.WebAPIException.UNKNOWN_ERR ,
- 'TypeMismatchError' : tizen.WebAPIException.TYPE_MISMATCH_ERR ,
- 'InvalidValuesError' : tizen.WebAPIException.INVALID_VALUES_ERR ,
- 'IOError' : tizen.WebAPIException.IO_ERR ,
- 'ServiceNotAvailableError' : tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR ,
- 'SecurityError' : tizen.WebAPIException.SECURITY_ERR ,
- 'NetworkError' : tizen.WebAPIException.NETWORK_ERR ,
- 'NotSupportedError' : tizen.WebAPIException.NOT_SUPPORTED_ERR ,
- 'NotFoundError' : tizen.WebAPIException.NOT_FOUND_ERR ,
- 'InvalidAccessError' : tizen.WebAPIException.INVALID_ACCESS_ERR ,
- 'AbortError' : tizen.WebAPIException.ABORT_ERR ,
- 'QuotaExceededError' : tizen.WebAPIException.QUOTA_EXCEEDED_ERR ,
+ 'UnknownError' : WebAPIException.UNKNOWN_ERR ,
+ 'TypeMismatchError' : WebAPIException.TYPE_MISMATCH_ERR ,
+ 'InvalidValuesError' : WebAPIException.INVALID_VALUES_ERR ,
+ 'IOError' : WebAPIException.IO_ERR ,
+ 'ServiceNotAvailableError' : WebAPIException.SERVICE_NOT_AVAILABLE_ERR ,
+ 'SecurityError' : WebAPIException.SECURITY_ERR ,
+ 'NetworkError' : WebAPIException.NETWORK_ERR ,
+ 'NotSupportedError' : WebAPIException.NOT_SUPPORTED_ERR ,
+ 'NotFoundError' : WebAPIException.NOT_FOUND_ERR ,
+ 'InvalidAccessError' : WebAPIException.INVALID_ACCESS_ERR ,
+ 'AbortError' : WebAPIException.ABORT_ERR ,
+ 'QuotaExceededError' : WebAPIException.QUOTA_EXCEEDED_ERR ,
}
function callNative(cmd, args) {
var result = JSON.parse(resultString);
if (typeof result !== 'object') {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
if (result['status'] == 'success') {
var err = result['error'];
if(err) {
if(ExceptionMap[err.name]) {
- throw new tizen.WebAPIException(ExceptionMap[err.name], err.message);
+ throw new WebAPIException(ExceptionMap[err.name], err.message);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR, err.message);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR, err.message);
}
}
return false;
}
var PowerResource = {
- 'SCREEN': 'SCREEN',
- 'CPU': 'CPU'
+ 'SCREEN': 'SCREEN',
+ 'CPU': 'CPU'
};
/**
* @enum {string}
*/
var PowerScreenState = {
- 'SCREEN_OFF': 'SCREEN_OFF',
- 'SCREEN_DIM': 'SCREEN_DIM',
- 'SCREEN_NORMAL': 'SCREEN_NORMAL',
- 'SCREEN_BRIGHT': 'SCREEN_BRIGHT'
+ 'SCREEN_OFF': 'SCREEN_OFF',
+ 'SCREEN_DIM': 'SCREEN_DIM',
+ 'SCREEN_NORMAL': 'SCREEN_NORMAL',
+ 'SCREEN_BRIGHT': 'SCREEN_BRIGHT'
};
/**
* @enum {string}
*/
var PowerCpuState = {
- 'CPU_AWAKE': 'CPU_AWAKE'
+ 'CPU_AWAKE': 'CPU_AWAKE'
};
/**
*/
PowerManager.prototype.request = function(resource, state) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']},
- {'name' : 'state', 'type': types_.ENUM, 'values' : ['SCREEN_OFF', 'SCREEN_DIM', 'SCREEN_NORMAL', 'SCREEN_BRIGHT', 'CPU_AWAKE']}
+ {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']},
+ {'name' : 'state', 'type': types_.ENUM, 'values' : ['SCREEN_OFF', 'SCREEN_DIM', 'SCREEN_NORMAL', 'SCREEN_BRIGHT', 'CPU_AWAKE']}
]);
-
+
var nativeParam = {
};
if (args['state']) {
nativeParam['state'] = args.state;
}
-
+
try {
var syncResult = callNative('PowerManager_request', nativeParam);
// if you need synchronous result from native function using 'syncResult'.
*/
PowerManager.prototype.release = function(resource) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']}
+ {'name' : 'resource', 'type': types_.ENUM, 'values' : ['SCREEN', 'CPU']}
]);
if (!PowerResource.hasOwnProperty(args.resource))
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
-
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
+
var nativeParam = {
};
if (args['resource']) {
nativeParam['resource'] = args.resource;
- }
+ }
try {
var syncResult = callNative('PowerManager_release', nativeParam);
// if you need synchronous result from native function using 'syncResult'.
var nativeParam = {
};
var syncResult = 0;
-
+
try {
syncResult = callNative('PowerManager_getScreenBrightness', nativeParam);
// if you need synchronous result from native function using 'syncResult'.
} catch(e) {
throw e;
- }
+ }
return syncResult;
}
*/
PowerManager.prototype.setScreenBrightness = function(brightness) {
var args = validator_.validateArgs(arguments, [
- {'name' : 'brightness', 'type': types_.DOUBLE}
+ {'name' : 'brightness', 'type': types_.DOUBLE}
]);
if (args.brightness < 0 || args.brightness > 1)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
-
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
+
var nativeParam = {
'brightness': args.brightness
};
var nativeParam = {
};
var syncResult = 0;
-
- try {
+
+ try {
syncResult = callNative('PowerManager_isScreenOn', nativeParam);
// if you need synchronous result from native function using 'syncResult'.
} catch(e) {
PowerManager.prototype.restoreScreenBrightness = function() {
var nativeParam = {
};
-
+
try {
var syncResult = callNative('PowerManager_restoreScreenBrightness', nativeParam);
// if you need synchronous result from native function using 'syncResult'.
PowerManager.prototype.turnScreenOn = function() {
var nativeParam = {
};
-
+
try {
var syncResult = callNative('PowerManager_turnScreenOn', nativeParam);
// if you need synchronous result from native function using 'syncResult'.
if (args.frequency) {
if (args.frequency < this.frequencyLowerBound
|| args.frequency > this.frequencyUpperBound)
- throw new tizen.WebAPIException(
- tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(
+ WebAPIException.INVALID_VALUES_ERR,
'Frequency out of bounds');
}
var result = native_.callSync('FMRadio_Start', {
if (!thisObj.isStarted) {
setTimeout(function() {
if (!T_.isNullOrUndefined(errorCallback)) {
- errorCallback(new tizen.WebAPIException(
- tizen.WebAPIException.SERVICE_NOT_AVAILABLE_ERR,
+ errorCallback(new WebAPIException(
+ WebAPIException.SERVICE_NOT_AVAILABLE_ERR,
'Service is not available.'));
}
}, 0);
var index = _supportedSensors.indexOf(args.type);
if (index === -1) {
- throw new tizen.WebAPIException(tizen.WebAPIException.NOT_SUPPORTED_ERR, 'Not supported.');
+ throw new WebAPIException(WebAPIException.NOT_SUPPORTED_ERR, 'Not supported.');
} else if (_supportedSensors[index] === SensorType.LIGHT) {
return new LightSensor();
} else if (_supportedSensors[index] === SensorType.MAGNETIC) {
]);
if (args.volume < 0 || args.volume > 1) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
}
var result = native_.callSync('SoundManager_setVolume', args);
if (native_.isFailure(result)) {
if (_propertyContainer[property]){
return new _propertyContainer[property].constructor(data);
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.');
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.');
}
};
propertyArray.push(new _propertyContainer[property].constructor(jsonArray[i]));
}
} else {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.');
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.');
}
return propertyArray;
};
]);
var propObject = _propertyContainer[args.property];
if (!propObject) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.');
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + args.property + ' is not supported.');
}
var callback = function(result) {
if (native_.isFailure(result)) {
var propObject = _propertyContainer[property];
if (!propObject) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.');
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR, 'Property with id: ' + property + ' is not supported.');
}
var callbackBroadcastFunction = propObject.broadcastFunction;
var signalLabel = propObject.signalLabel;
return p;
}
}
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR, 'Listener with id: ' + watchId + ' does not exist.');
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR, 'Listener with id: ' + watchId + ' does not exist.');
};
var _unregisterListener = function (watchId, isTimeout) {
var native_ = new xwalk.utils.NativeManager(extension);
function throwException_(err) {
- throw new tizen.WebAPIException(err.code, err.name, err.message);
+ throw new WebAPIException(err.code, err.name, err.message);
}
function callSync_(msg) {
exports.isLeapYear = function(year) {
if (year === undefined)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
};
function _throwProperTizenException(e) {
if (e instanceof TypeError)
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
else if (e instanceof RangeError)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
else
- throw new tizen.WebAPIException(tizen.WebAPIException.UNKNOWN_ERR);
+ throw new WebAPIException(WebAPIException.UNKNOWN_ERR);
}
var TimeDurationUnit = {
this.date_ = new Date(year, month, day, hours, minutes, seconds, milliseconds);
if (tizen.time.getAvailableTimezones().indexOf(this.timezone_) < 0)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
};
function getTimezoneOffset(_timezone, _timeInMs) {
}]);
if (!args.timezone)
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR);
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR);
var d = new tizen.TZDate(new Date(this.date_.getTime()), args.timezone);
return d.addDuration(new tizen.TimeDuration((getTimezoneOffset(args.timezone) * 1) +
(getTimezoneOffset(this.timezone_) * -1)));
// Tizen API Specification:
// https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.web.device.apireference/tizen/tizen.html
-function __isObject(object) {
- return object instanceof Object;
-}
-
-function __isUndefined(object) {
- return object === void 0;
-}
-
-function __isNumber(object) {
- return typeof object === 'number';
-}
-
-// WARNING! This list should be in sync with the equivalent enum
-// located at tizen.h. Remember to update tizen.h if you change
-// something here.
-var errors = {
- NO_ERROR: 0,
- UNKNOWN_ERR: -1,
-
- INDEX_SIZE_ERR: 1,
- DOMSTRING_SIZE_ERR: 2,
- HIERARCHY_REQUEST_ERR: 3,
- WRONG_DOCUMENT_ERR: 4,
- INVALID_CHARACTER_ERR: 5,
- NO_DATA_ALLOWED_ERR: 6,
- NO_MODIFICATION_ALLOWED_ERR: 7,
- NOT_FOUND_ERR: 8,
- NOT_SUPPORTED_ERR: 9,
- INUSE_ATTRIBUTE_ERR: 10,
- INVALID_STATE_ERR: 11,
- SYNTAX_ERR: 12,
- INVALID_MODIFICATION_ERR: 13,
- NAMESPACE_ERR: 14,
- INVALID_ACCESS_ERR: 15,
- VALIDATION_ERR: 16,
- TYPE_MISMATCH_ERR: 17,
- SECURITY_ERR: 18,
- NETWORK_ERR: 19,
- ABORT_ERR: 20,
- URL_MISMATCH_ERR: 21,
- QUOTA_EXCEEDED_ERR: 22,
- TIMEOUT_ERR: 23,
- INVALID_NODE_TYPE_ERR: 24,
- DATA_CLONE_ERR: 25,
-
- // Error codes for these errors are not really defined anywhere.
- INVALID_VALUES_ERR: 100,
- IO_ERR: 101,
- PERMISSION_DENIED_ERR: 102,
- SERVICE_NOT_AVAILABLE_ERR: 103,
- DATABASE_ERR: 104
-};
-
-var code_to_name = {};
-code_to_name[errors['NO_ERROR']] = 'NoError';
-code_to_name[errors['UNKNOWN_ERR']] = 'UnknownError';
-code_to_name[errors['INDEX_SIZE_ERR']] = 'IndexSizeError';
-code_to_name[errors['DOMSTRING_SIZE_ERR']] = 'DOMStringSizeError';
-code_to_name[errors['HIERARCHY_REQUEST_ERR']] = 'HierarchyRequestError';
-code_to_name[errors['WRONG_DOCUMENT_ERR']] = 'WrongDocumentError';
-code_to_name[errors['INVALID_CHARACTER_ERR']] = 'InvalidCharacterError';
-code_to_name[errors['NO_DATA_ALLOWED_ERR']] = 'NoDataAllowedError';
-code_to_name[errors['NO_MODIFICATION_ALLOWED_ERR']] = 'NoModificationAllowedError';
-code_to_name[errors['NOT_FOUND_ERR']] = 'NotFoundError';
-code_to_name[errors['NOT_SUPPORTED_ERR']] = 'NotSupportedError';
-code_to_name[errors['INUSE_ATTRIBUTE_ERR']] = 'InuseAttributeError';
-code_to_name[errors['INVALID_STATE_ERR']] = 'InvalidStateError';
-code_to_name[errors['SYNTAX_ERR']] = 'SyntaxError';
-code_to_name[errors['INVALID_MODIFICATION_ERR']] = 'InvalidModificationError';
-code_to_name[errors['NAMESPACE_ERR']] = 'NamespaceError';
-code_to_name[errors['INVALID_ACCESS_ERR']] = 'InvalidAccessError';
-code_to_name[errors['VALIDATION_ERR']] = 'ValidationError';
-code_to_name[errors['TYPE_MISMATCH_ERR']] = 'TypeMismatchError';
-code_to_name[errors['SECURITY_ERR']] = 'SecurityError';
-code_to_name[errors['NETWORK_ERR']] = 'NetworkError';
-code_to_name[errors['ABORT_ERR']] = 'AbortError';
-code_to_name[errors['URL_MISMATCH_ERR']] = 'URLMismatchError';
-code_to_name[errors['QUOTA_EXCEEDED_ERR']] = 'QuotaExceededError';
-code_to_name[errors['TIMEOUT_ERR']] = 'TimeoutError';
-code_to_name[errors['INVALID_NODE_TYPE_ERR']] = 'InvalidNodeTypeError';
-code_to_name[errors['DATA_CLONE_ERR']] = 'DataCloneError';
-
-code_to_name[errors['INVALID_VALUES_ERR']] = 'InvalidValuesError';
-code_to_name[errors['IO_ERR']] = 'IOError';
-code_to_name[errors['PERMISSION_DENIED_ERR']] = 'PermissionDeniedError';
-code_to_name[errors['SERVICE_NOT_AVAILABLE_ERR']] = 'ServiceNotAvailableError';
-code_to_name[errors['DATABASE_ERR']] = 'DatabaseError';
-
-var name_to_code = {};
-Object.keys(errors).forEach(function(key) {
- name_to_code[code_to_name[errors[key]]] = errors[key];
-});
-
-
-/**
- * Generic exception interface.
- *
- * @param {number} code 16-bit error code.
- * @param {string} message An error message that describes the details of an encountered error.
- * @param {string} name An error type.
- */
-var WebAPIException = function(code, message, name) {
- var code_ = 0;
- var name_ = code_to_name[code];
- var message_ = 'Unknown error';
-
- switch (arguments.length) {
- case 1:
- var error = arguments[0];
- if (__isObject(error)) {
- code_ = error.code;
- name_ = error.name;
- message_ = error.message;
- if (__isUndefined(code_) && !__isUndefined(name_))
- code_ = name_to_code[name_];
- if (__isUndefined(name_) && !__isUndefined(code_))
- name_ = code_to_name[code_];
- } else if (__isNumber(error)) {
- // backward compatibility with crosswalk implementation
- code_ = error;
- name_ = code_to_name[code];
- message_ = name_;
- }
- break;
- case 2:
- if (__isNumber(arguments[0])) {
- code_ = arguments[0];
- if (!__isUndefined(code_to_name[code_])) {
- name_ = code_to_name[code_];
- }
- } else {
- name_ = String(arguments[0]);
- if (!__isUndefined(name_to_code[name_])) {
- code_ = name_to_code[name_];
- }
- }
- message_ = String(arguments[1]);
- break;
- case 3:
- // backward compatibility with crosswalk implementation
- code_ = Number(arguments[0]);
- message_ = String(arguments[1]);
- name_ = String(arguments[2]);
- break;
- default:
- return;
- }
-
- // attributes
- Object.defineProperties(this, {
- code: {value: code_, writable: false, enumerable: true},
- name: {value: name_, writable: false, enumerable: true},
- message: {value: message_, writable: false, enumerable: true}
- });
-
- this.constructor.prototype.__proto__ = Error.prototype;
- Error.captureStackTrace(this, this.constructor);
-};
-
-WebAPIException.prototype.toString = function() {
- return this.name + ': ' + this.message;
-};
-
-
-var error_constants = {};
-for (var prop in errors) {
- error_constants[prop] = {value: errors[prop], writable: false, enumerable: true};
-}
-Object.defineProperties(WebAPIException, error_constants);
-Object.defineProperties(WebAPIException.prototype, error_constants);
-exports.WebAPIException = WebAPIException;
-exports.WebAPIError = WebAPIException;
+// WebAPIException and WebAPIError definition moved to src/utils/utils_api.js
+// for compliance reasons. You can find more info there.
/**
}
if (!obj.hasOwnProperty(props[i])) {
if (i === props.length - 1) {
- throw new tizen.WebAPIException('InvalidValuesError', 'Property "' + attributeName +
+ throw new WebAPIException('InvalidValuesError', 'Property "' + attributeName +
'" is not valid');
}
return null;
/**
* This is a common interface used by different types of object filters.
*/
-exports.AbstractFilter = function() {};
+var AbstractFilter = function() {};
/**
}
});
};
-exports.AttributeFilter.prototype = new exports.AbstractFilter();
+exports.AttributeFilter.prototype = new AbstractFilter();
//TODO: Move filtering to native code
exports.AttributeFilter.prototype._filter = function(element) {
});
};
-exports.AttributeRangeFilter.prototype = new exports.AbstractFilter();
+exports.AttributeRangeFilter.prototype = new AbstractFilter();
//TODO: Move filtering to native code
exports.AttributeRangeFilter.prototype._filter = function(element) {
return;
for (var i in filterList) {
- var valid = (filterList[i] instanceof tizen.AbstractFilter);
+ var valid = (filterList[i] instanceof AbstractFilter);
if (!valid)
return;
}
});
};
-exports.CompositeFilter.prototype = new exports.AbstractFilter();
+exports.CompositeFilter.prototype = new AbstractFilter();
//TODO: Move filtering to native code
exports.CompositeFilter.prototype._filter = function(element) {
]);
if (args.volume < 0 || args.volume > 100) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'Volume is out of range: ' + args.volume, 'InvalidValuesError');
}
if (arguments.length < 1) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
'no volume argument: ' + arguments.length, 'InvalidValuesError');
}
}
]);
if (args.nStart < 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
"nStart is lower than 0");
}
if (args.number < 0) {
- throw new tizen.WebAPIException(tizen.WebAPIException.INVALID_VALUES_ERR,
+ throw new WebAPIException(WebAPIException.INVALID_VALUES_ERR,
"number is lower than 0");
}
native.call('TVChannelManager_getChannelList', {
var mode = Display3DEffectMode[native.getResultObject(ret)];
if (!mode) {
var error_msg = 'Unknown 3D effect mode (' + reply.result + ')';
- throw new tizen.WebAPIException(0, error_msg, UNKNOWN_ERROR);
+ throw new WebAPIException(0, error_msg, UNKNOWN_ERROR);
}
return mode;
};
function _toDouble(val) {
var ret = Number(val);
if (isNaN(ret) || !isFinite(ret)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + String(val) + ' to double.');
}
return ret;
return val;
}
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + String(val) + ' to ' + String(t[0].name) + '.');
}
return val;
}
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + String(val) + ' to function.');
}
return val;
}
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + String(val) + ' to array.');
}
return val;
}
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + String(val) + ' to dictionary.');
}
return v;
}
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Cannot convert ' + v + ' to enum.');
}
case this.Types.LISTENER:
if (_type.isNull(val)) {
if (!nullable) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "' + name + '" cannot be null.');
}
} else {
if (!_type.isFunction(val)) {
if (_type.isEmptyObject(val)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "' + name + '" shouldn\'t be an empty object.');
}
}
if (!_type.isObject(val)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "' + name + '" should be an object.');
}
for (var ii = 0; ii < values.length; ++ii) {
default:
func = function(val) {
if (!(val instanceof values)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Items of array "' + name + '" should be of type: ' + values + '.');
}
return val;
break;
default:
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Unknown type: "' + type + '".');
}
var _validator = d[i].validator;
if (_type.isFunction(_validator) && !_validator(val)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Argument "' + name + '" did not pass additional validation.');
}
if (!(obj instanceof instance) || obj._previouslyConstructed) {
// There is no TypeError exception in Tizen 2.3.0 API spec but it's required by current TCTs.
// For Tizen compliance it's wrapped into WebAPIException.
- throw new tizen.WebAPIException('TypeError', 'Constructor cannot be called as function.');
+ throw new WebAPIException('TypeError', 'Constructor cannot be called as function.');
}
Object.defineProperty(obj, '_previouslyConstructed', {
!_type.isFunction(extension.postMessage) ||
!_type.isFunction(extension.internal.sendSyncMessage) ||
!_type.isFunction(extension.setMessageListener)) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR,
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
'Wrong extension object passed');
}
NativeManager.prototype.addListener = function(name, callback) {
if (!_type.isString(name) || !name.length) {
- throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR);
+ throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR);
}
this.listeners_[name] = callback;
};
NativeManager.prototype.getErrorObject = function(result) {
- return new tizen.WebAPIException(result.error);
+ return new WebAPIException(result.error);
};
NativeManager.prototype.callIfPossible = function(callback) {
var result = extension.internal.sendSyncMessage(json);
var obj = JSON.parse(result);
if (obj.error)
- throw new tizen.WebAPIException(obj.code, obj.name, obj.message);
+ throw new WebAPIException(obj.code, obj.name, obj.message);
return obj.result;
},
async: function (data) {
return new Bridge;
});
-// WebAPIException and WebAPIError
-
+// WebAPIException and WebAPIError definition moved to Utils for compliance
+// reasons with blink-wrt environment.
+// In blink-wrt the original Tizen module is loaded, which is not providing exception constructor.
+// As modules needs exceptions internally so they are loaded here for now.
+// See http://168.219.209.56/gerrit/#/c/23472/ for more details.
+// In future exception definition could be moved back to Tizen module.
function __isObject(object) {
return object instanceof Object;
}
}
// attributes
- var attributes = {
+ Object.defineProperties(this, {
code: {value: code_, writable: false, enumerable: true},
name: {value: name_, writable: false, enumerable: true},
message: {value: message_, writable: false, enumerable: true}
- };
-
- for (var error in errors) {
- attributes[error] = { value: errors[error], writable: false, enumerable: true}
- }
-
- Object.defineProperties(this, attributes);
+ });
this.constructor.prototype.__proto__ = Error.prototype;
Error.captureStackTrace(this, this.constructor);
return this.name + ': ' + this.message;
};
-function getExceptionClass() {
- return WebAPIException;
-}
-Utils.prototype.getExceptionClass = getExceptionClass;
-Utils.prototype.getErrorClass = getExceptionClass;
+var error_constants = {};
+for (var prop in errors) {
+ error_constants[prop] = {value: errors[prop], writable: false, enumerable: true};
+}
+Object.defineProperties(WebAPIException, error_constants);
+Object.defineProperties(WebAPIException.prototype, error_constants);
+
+
+// Export WebAPIException and WebAPIError into global scope.
+// For compliance reasons their constructors should not be exported in tizen namespace,
+// but should be available internally to allow throwing exceptions from modules.
+var scope;
+if (typeof window !== 'undefined') {
+ scope = window;
+} else if(typeof global !== 'undefined') {
+ scope = global;
+}
+scope = scope || {};
+scope.WebAPIException = WebAPIException;
+scope.WebAPIError = WebAPIException;
Utils.prototype.type = _type;
Utils.prototype.converter = _converter;